Package org.jpedal.objects

Examples of org.jpedal.objects.GraphicsState


    /**
     * used to display non-PDF files
     */
    public void addImage(BufferedImage img) {
        GraphicsState gs = new GraphicsState();
        gs.CTM[0][0] = img.getWidth();
        gs.CTM[1][1] = img.getHeight();

        decode_pdf.getDynamicRenderer().drawImage(1, img, gs, false, "image", PDFImageProcessing.NOTHING, -1);

View Full Code Here


        dvr.paint(null, null, null);

        //if odd matrix can break text and already applied for drawing so now remove
        g2.setClip(null);

        GraphicsState gs = new GraphicsState();
        gs.CTM[0][0] = fw;
        gs.CTM[1][0] = 0.0f;
        gs.CTM[2][0] = 0f;
        gs.CTM[0][1] = 0.0f;
        gs.CTM[1][1] = fh;
View Full Code Here

            //reset count
            imageCount=0;


            gs = new GraphicsState(0,0);/* take out min's%%*/

            //get the binary data from the file
            byte[] b_data;

            byte[][] pageContents= null;
View Full Code Here

            glyphDecoder.setDefaultColors(gs.getStrokeColor(),gs.getNonstrokeColor());

            /**
             * setup matrix so scales correctly
             **/
            GraphicsState currentGraphicsState=new GraphicsState(0,0);
            //multiply to get new CTM
            if(matrix!=null)
                currentGraphicsState.CTM =matrix;


View Full Code Here

         */
        int count=type.length;

        int currentType;

        GraphicsState gs;

        for(int i=0;i<count;i++){

            currentType=type[i];

            switch(currentType){
                case DynamicVectorRenderer.FILLOPACITY:
                    setGraphicsState(GraphicsState.FILL, ((Float)obj[i]).floatValue());
                    break;

                case DynamicVectorRenderer.STROKEOPACITY:
                    setGraphicsState(GraphicsState.STROKE, ((Float)obj[i]).floatValue());
                    break;

                case DynamicVectorRenderer.STROKEDSHAPE:
                    gs=new GraphicsState();
                    gs.setFillType(GraphicsState.STROKE);
                    gs.setStrokeColor(new PdfColor(colors[i].getRed(),colors[i].getGreen(),colors[i].getBlue()));
                    drawShape( (Shape)obj[i],gs, Cmd.S);

                    break;

                case DynamicVectorRenderer.FILLEDSHAPE:
                    gs=new GraphicsState();
                    gs.setFillType(GraphicsState.FILL);
                    gs.setNonstrokeColor(new PdfColor(colors[i].getRed(),colors[i].getGreen(),colors[i].getBlue()));
                    drawShape( (Shape)obj[i],gs, Cmd.F);

                    break;

                case DynamicVectorRenderer.CUSTOM:
                    drawCustom(obj[i]);

                    break;

                case DynamicVectorRenderer.IMAGE:
                    ImageObject imgObj=(ImageObject)obj[i];
                    gs=new GraphicsState();

                    gs.CTM=new float[][]{ {imgObj.image.getWidth(),0,1}, {0,imgObj.image.getHeight(),1}, {0,0,0}};

                    gs.x=imgObj.x;
                    gs.y=imgObj.y;

                    drawImage(this.pageNumber,imgObj.image, gs,false,"extImg"+i, PDFImageProcessing.NOTHING, -1);

                    break;

                case DynamicVectorRenderer.STRING:
                    TextObject textObj=(TextObject)obj[i];
                    gs=new GraphicsState();
                    float fontSize=textObj.font.getSize();
                    double[] afValues={fontSize,0f,0f,fontSize,0f,0f};
                    drawAffine(afValues);

                    drawTR(GraphicsState.FILL);
                    gs.setTextRenderType(GraphicsState.FILL);
                    gs.setNonstrokeColor(new PdfColor(colors[i].getRed(),colors[i].getGreen(),colors[i].getBlue()));
                    drawText(null,textObj.text,gs,textObj.x,-textObj.y,textObj.font); //note y is negative

                    break;

                case 0:
View Full Code Here

         * convert text to shape and draw shape instead
         * Generally text at 1000x1000 matrix so we scale down by 1000 and then up by fontsize
         */
        if(embeddedGlyph!=null && embeddedGlyph.getShape()!=null && !glyf.equals(" ") ){

            GraphicsState TextGs=gs;//new GraphicsState();

            //name we will store draw code under as routine
            String JSRoutineName;

            //check all chars letters or numbers and use int value if invalid
            boolean isInvalid=false;
            for(int aa=0;aa<glyf.length();aa++){
                if(!Character.isLetterOrDigit(glyf.charAt(aa))){
                    isInvalid=true;
                }

                //exit if wrong
                if(isInvalid)
                    break;
            }

            if(isInvalid)
                JSRoutineName=currentFontData.getFontID()+Integer.toHexString((int)glyf.charAt(0));
            else
                JSRoutineName=currentFontData.getFontID()+glyf;

            //ensure starts with letter
            if(!Character.isLetter(JSRoutineName.charAt(0)))
                JSRoutineName= 's' +JSRoutineName;

            //flag to show if generated
            String cacheKey= currentFontData.getBaseFontName() + '.' + JSRoutineName;

            //see if we have already decoded glyph and use that data to reduce filesize
            boolean isAlreadyDecoded=glyfsRasterized.containsKey(cacheKey);

            //get the glyph as textGlyf shape (which we already have to render)
            Area textGlyf = (Area) embeddedGlyph.getShape().clone();

            //adjust GS to work correctly
            TextGs.setClippingShape(null);
            TextGs.setFillType(gs.getTextRenderType());

            /**
             *  adjust scaling to factor in font size
             */

 
View Full Code Here

                        int factor=1;
                        double[] fontMatrix=pdfObject.getDoubleArray(PdfDictionary.FontMatrix);
                        if(fontMatrix!=null && fontMatrix[0]==1 && (fontMatrix[3]==1 || fontMatrix[3]==-1))
                        factor=10;
                       
                        GraphicsState gs=new GraphicsState(0,0);
                        gs.CTM = new float[][]{{factor,0,0},
                                {0,factor,0},{0,0,1}
                        };

                        T3Size t3 = glyphDecoder.decodePageContent(glyphObj, gs);
View Full Code Here

TOP

Related Classes of org.jpedal.objects.GraphicsState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.