Examples of PDFPaint


Examples of com.sun.pdfview.PDFPaint

     */
    public PDFPaint getPaint(PDFObject patternObj, float[] components,
                             Map resources)
        throws IOException
    {
        PDFPaint basePaint = null;
       
        if (getBase() != null) {
            basePaint = getBase().getPaint(components);
        }
       
View Full Code Here

Examples of com.sun.pdfview.PDFPaint

            PDFObject[] bgObjs = bgObj.getArray();
            float[] bgArray = new float[bgObjs.length];
            for (int i = 0; i < bgArray.length; i++) {
                bgArray[i] = bgObjs[i].getFloatValue();
            }
            PDFPaint paint = cs.getPaint(bgArray);
            shader.setBackground(paint);         
        }
       
        // read the bounding box (optional)
        PDFObject bboxObj = shaderObj.getDictRef("BBox");
View Full Code Here

Examples of com.sun.pdfview.PDFPaint

            PDFObject[] bgObjs = bgObj.getArray();
            float[] bgArray = new float[bgObjs.length];
            for (int i = 0; i < bgArray.length; i++) {
                bgArray[i] = bgObjs[i].getFloatValue();
            }
            PDFPaint paint = cs.getPaint(bgArray);
            shader.setBackground(paint);         
        }
       
        // read the bounding box (optional)
        PDFObject bboxObj = shaderObj.getDictRef("BBox");
View Full Code Here

Examples of com.sun.pdfview.PDFPaint

     */
    public PDFPaint getPaint(PDFObject patternObj, float[] components,
                             Map resources)
        throws IOException
    {
        PDFPaint basePaint = null;
       
        if (getBase() != null) {
            basePaint = getBase().getPaint(components);
        }
       
View Full Code Here

Examples of org.jpedal.color.PdfPaint

  public void drawEmbeddedText(float[][] Trm, int fontSize, PdfGlyph embeddedGlyph,
                                 Object javaGlyph, int type, GraphicsState gs, AffineTransform at, String glyf, PdfFont currentFontData, float glyfWidth) {

    if (type == TEXT) {

      PdfPaint currentCol = null, fillCol = null;
      int text_fill_type = gs.getTextRenderType();

      //for a fill
      if ((text_fill_type & GraphicsState.FILL) == GraphicsState.FILL) {
        fillCol = gs.getNonstrokeColor();
      }

      //and/or do a stroke
      if ((text_fill_type & GraphicsState.STROKE) == GraphicsState.STROKE) {
        currentCol = gs.getStrokeColor();
      }

      //set the stroke to current value
      Stroke newStroke = gs.getStroke();
      g2.setStroke(newStroke);

      AffineTransform def = g2.getTransform();

      g2.translate(Trm[2][0], Trm[2][1]);

      g2.transform(at);

      renderText(Trm[2][0], Trm[2][1], text_fill_type, (Area) javaGlyph, null, currentCol, fillCol, gs.getAlpha(GraphicsState.STROKE),
                    gs.getAlpha(GraphicsState.FILL));

      g2.setTransform(def);
    } else {

      PdfPaint strokeCol = null, fillCol = null;
      int text_fill_type = gs.getTextRenderType();

      //for a fill
      if ((text_fill_type & GraphicsState.FILL) == GraphicsState.FILL) {
        fillCol = gs.getNonstrokeColor();
View Full Code Here

Examples of org.jpedal.color.PdfPaint

            GenericColorSpace newColorSpace= ColorspaceFactory.getColorSpaceInstance(currentPdfFile, ColorSpace, shadingColorspacesObjects);

            newColorSpace.setPrinting(isPrinting);

            /**setup shading object*/

            @SuppressWarnings("UnusedAssignment") PdfPaint shading=null;

            if(shading!=null){
                /**
 
View Full Code Here

Examples of org.jpedal.color.PdfPaint

      float strokeOpacity=1.0f;
      float x,y ;
      int iCount=0,cCount=0,sCount=0,fsCount=-1,lwCount=0,afCount=-1,tCount=0,stCount=0,
      fillCount=0,strokeCount=0,trCount=0,opCount=0,
      stringCount=0;//note af is 1 behind!
      PdfPaint textStrokeCol=null,textFillCol=null,fillCol=null,strokeCol = null;
      Stroke currentStroke=null;

      //if we reuse image this is pointer to live image
      int imageUsed;

      if(colorsLocked){
        strokeCol=this.strokeCol;
        fillCol=this.fillCol;
      }

      //setup first time something to highlight
      if(highlightsNeedToBeGenerated && areas!=null && highlights!=null)
        generateHighlights(g2,count, objectTypes,pageObjects, a,b,c,d,afValues1,afValues2,afValues3,afValues4,fsValues,fontBounds);

      /**
       * now draw all shapes
       */
      for(int i=0;drawPDFShapes && i<count;i++){

        //    if(i>4800)
        //break;

        boolean ignoreItem=false;

        type=objectTypes[i];

        //ignore items flagged as deleted
        if(type== DynamicVectorRenderer.DELETED_IMAGE)
          continue;

        Rectangle currentArea=null;

        //exit if later paint recall
        if(currentThreadID!=paintThreadID){
          paintThreadCount--;

          return null;
        }


        if(type>0){

          x=x_coord[i];
          y=y_coord[i];

          currentObject=pageObjects[i];

          //swap in replacement image
          if(type==DynamicVectorRenderer.REUSED_IMAGE){
            type=DynamicVectorRenderer.IMAGE;
            imageUsed= (Integer) currentObject;
            currentObject=pageObjects[imageUsed];
          }else
            imageUsed=-1;

          /**
           * workout area occupied by glyf
           */
          if(currentArea==null)
            currentArea = getObjectArea(afValues1, fsValues, afValues2,afValues3, afValues4, pageObjects, areas, type, x, y,fsCount, afCount, i);

          ignoreItem=false;

          //see if we need to draw
          if(currentArea!=null){

            //was glyphArea, changed back to currentArea to fix highlighting issue in Sams files.
            //last width test for odd print issue in phonobingo
            if (type < 7 && (userAnnot != null) && ((!userAnnot.intersects(currentArea)))&& currentArea.width>0) {
              ignoreItem = true;
            }
          }
          //                }else if((optimiseDrawing)&&(rotation==0)&&(dirtyRegion!=null)&&(type!=DynamicVectorRenderer.STROKEOPACITY)&&
          //                        (type!=DynamicVectorRenderer.FILLOPACITY)&&(type!=DynamicVectorRenderer.CLIP)
          //                        &&(currentArea!=null)&&
          //                        ((!dirtyRegion.intersects(currentArea))))
          //                    ignoreItem=true;

          if(ignoreItem || (lastItemPainted!=-1 && i<lastItemPainted)){
            //keep local counts in sync
            switch (type) {

            case DynamicVectorRenderer.SHAPE:
              sCount++;
              break;
            case DynamicVectorRenderer.IMAGE:
              iCount++;
              break;
            case DynamicVectorRenderer.REUSED_IMAGE:
              iCount++;
              break;
            case DynamicVectorRenderer.CLIP:
              cCount++;
              break;
            case DynamicVectorRenderer.FONTSIZE:
              fsCount++;
              break;
            case DynamicVectorRenderer.LINEWIDTH:
              lwCount++;
              break;
            case DynamicVectorRenderer.TEXTCOLOR:
              tCount++;
              break;
            case DynamicVectorRenderer.FILLCOLOR:
              fillCount++;
              break;
            case DynamicVectorRenderer.STROKECOLOR:
              strokeCount++;
              break;
            case DynamicVectorRenderer.STROKE:
              stCount++;
              break;
            case DynamicVectorRenderer.TR:
              trCount++;
              break;
            }

          }else{


            if(!isInitialised && !stopG2setting){

              //set hints to produce high quality image
              g2.setRenderingHints(hints);
              isInitialised=true;
            }

            paintedCount++;

            if(currentTR==GraphicsState.INVISIBLE){
              needsHighlights = true;
            }

            Rectangle highlight = null;

            switch (type) {

            case DynamicVectorRenderer.SHAPE:

              if(debug)
                System.out.println("Shape");

              if(newClip){
                RenderUtils.renderClip(clipToUse, dirtyRegion,defaultClip,g2);
                newClip=false;
              }

              Shape s=null;
              if(endItem!=-1 && endItem<i){
                s = g2.getClip();
                g2.setClip(defaultClip);

              }

              renderShape(defaultClip,fillType[sCount],strokeCol,fillCol, currentStroke,(Shape)currentObject,strokeOpacity,fillOpacity);

              if(endItem!=-1 && endItem<i)
                g2.setClip(s);

              sCount++;

              break;

            case DynamicVectorRenderer.TEXT:

              if(debug)
                System.out.println("Text");

              if(newClip){
                RenderUtils.renderClip(clipToUse, dirtyRegion,defaultClip,g2);
                newClip=false;
              }

              if(!invertHighlight)
                highlight = setHighlightForGlyph(currentArea,highlights);

              if(hasOCR && highlight!=null){
                String key=highlight.x+" "+highlight.y;
                if(ocr_used.get(key)==null){

                  ocr_used.put(key,"x"); //avoid multiple additions
                  ocr_highlights.addElement(highlight);
                }
              }

              AffineTransform def=g2.getTransform();

              renderHighlight(highlight, g2);

              g2.transform(new AffineTransform(afValues1[afCount],afValues2[afCount],-afValues3[afCount],-afValues4[afCount],x,y));

              renderText(x,y, currentTR,(Area)currentObject, highlight, textStrokeCol,textFillCol,strokeOpacity,fillOpacity);

              g2.setTransform(def);

              break;

            case DynamicVectorRenderer.TRUETYPE:

              if(debug)
                System.out.println("Truetype");

              if(newClip){
                RenderUtils.renderClip(clipToUse, dirtyRegion,defaultClip,g2);
                newClip=false;
              }

              //hack to fix exceptions in a PDF using this code to create ReadOnly image
              if(afCount==-1)
                break;

              AffineTransform aff=new AffineTransform(afValues1[afCount],afValues2[afCount],afValues3[afCount],afValues4[afCount],x,y);

              if(!invertHighlight)
                highlight = setHighlightForGlyph(currentArea,highlights);

              if(hasOCR && highlight!=null){

                String key=highlight.x+" "+highlight.y;
                if(ocr_used.get(key)==null){

                  ocr_used.put(key,"x"); //avoid multiple additions
                  ocr_highlights.addElement(highlight);
                }
              }

              renderHighlight(highlight, g2);
              renderEmbeddedText(currentTR,currentObject,DynamicVectorRenderer.TRUETYPE,aff,highlight,textStrokeCol,textFillCol,strokeOpacity,fillOpacity,lineWidth);

              break;

            case DynamicVectorRenderer.TYPE1C:

              if(debug)
                System.out.println("Type1c");

              if(newClip){
                RenderUtils.renderClip(clipToUse, dirtyRegion,defaultClip,g2);
                newClip=false;
              }

              aff=new AffineTransform(afValues1[afCount],afValues2[afCount],afValues3[afCount],afValues4[afCount],x,y);

              if(!invertHighlight)
                highlight = setHighlightForGlyph(currentArea,highlights);

              if(hasOCR && highlight!=null){
                String key=highlight.x+" "+highlight.y;
                if(ocr_used.get(key)==null){

                  ocr_used.put(key,"x"); //avoid multiple additions
                  ocr_highlights.addElement(highlight);

                }
              }

              renderHighlight(highlight, g2);

              renderEmbeddedText(currentTR,currentObject,DynamicVectorRenderer.TYPE1C,aff,highlight,textStrokeCol,textFillCol,strokeOpacity,fillOpacity,lineWidth);

              break;

            case DynamicVectorRenderer.TYPE3:

              if(debug)
                System.out.println("Type3");

              if(newClip){
                RenderUtils.renderClip(clipToUse, dirtyRegion,defaultClip,g2);
                newClip=false;
              }

              aff=new AffineTransform(afValues1[afCount],afValues2[afCount],afValues3[afCount],afValues4[afCount],x,y);

              if(!invertHighlight)
                highlight = setHighlightForGlyph(currentArea,highlights);

              if(hasOCR && highlight!=null){
                String key=highlight.x+" "+highlight.y;
                if(ocr_used.get(key)==null){

                  ocr_used.put(key,"x"); //avoid multiple additions
                  ocr_highlights.addElement(highlight);

                }
              }

              renderHighlight(highlight, g2);
              renderEmbeddedText(currentTR,currentObject,DynamicVectorRenderer.TYPE3,aff,highlight, textStrokeCol,textFillCol,strokeOpacity,fillOpacity,lineWidth);

              break;

            case DynamicVectorRenderer.IMAGE:

              if(newClip){
                RenderUtils.renderClip(clipToUse, dirtyRegion,defaultClip,g2);
                newClip=false;
              }

              renderImage(afValues1, afValues2, afValues3,afValues4, pageObjects, imageOptions,currentObject, fillOpacity, x, y, iCount, afCount, imageUsed, i);

              iCount++;

              break;

            case DynamicVectorRenderer.CLIP:
              clipToUse=pageClips[cCount];
              newClip=true;
              cCount++;
              break;

            case DynamicVectorRenderer.AF:
              afCount++;
              break;
            case DynamicVectorRenderer.FONTSIZE:
              fsCount++;
              break;
            case DynamicVectorRenderer.LINEWIDTH:
              lineWidth=lwValues[lwCount];
              lwCount++;
              break;
            case DynamicVectorRenderer.TEXTCOLOR:

              if(debug)
                System.out.println("TextCOLOR");

              textFillType=textFill[tCount];

              if(textFillType==GraphicsState.STROKE)
                textStrokeCol=(PdfPaint) text_color[tCount];
              else
                textFillCol=(PdfPaint) text_color[tCount];

              tCount++;
              break;
            case DynamicVectorRenderer.FILLCOLOR:

              if(debug)
                System.out.println("FillCOLOR");

              if(!colorsLocked)
                fillCol=(PdfPaint) fill_color[fillCount];

              fillCount++;

              break;
            case DynamicVectorRenderer.STROKECOLOR:

              if(debug)
                System.out.println("StrokeCOL");

              if(!colorsLocked){
                strokeCol=(PdfPaint)stroke_color[strokeCount];
                if(strokeCol!=null)
                  strokeCol.setScaling(cropX,cropH,scaling,0 ,0);
              }

              strokeCount++;
              break;

            case DynamicVectorRenderer.STROKE:

              currentStroke=(Stroke)stroke[stCount];

              if(debug)
                System.out.println("STROKE");

              stCount++;
              break;

            case DynamicVectorRenderer.TR:

              if(debug)
                System.out.println("TR");

              currentTR=TRvalues[trCount];
              trCount++;
              break;

            case DynamicVectorRenderer.STROKEOPACITY:

              if(debug)
                System.out.println("Stroke Opacity "+opacity[opCount]+" opCount="+opCount);

              strokeOpacity=opacity[opCount];
              opCount++;
              break;

            case DynamicVectorRenderer.FILLOPACITY:

              if(debug)
                System.out.println("Set Fill Opacity "+opacity[opCount]+" count="+opCount);

              fillOpacity=opacity[opCount];
              opCount++;
              break;

            case DynamicVectorRenderer.STRING:

              Shape s1 = g2.getClip();
              g2.setClip(defaultClip);
              AffineTransform defaultAf=g2.getTransform();
              String displayValue=(String)currentObject;

              double[] af=new double[6];

              g2.getTransform().getMatrix(af);

              if(af[2]!=0)
                af[2]=-af[2];
              if(af[3]!=0)
                af[3]=-af[3];
              g2.setTransform(new AffineTransform(af));

              Font javaFont=(Font) javaObjects[stringCount];

              g2.setFont(javaFont);

              if((currentTR & GraphicsState.FILL)==GraphicsState.FILL){

                if(textFillCol!=null)
                  textFillCol.setScaling(cropX,cropH,scaling,0 ,0);

                if(customColorHandler !=null){
                  customColorHandler.setPaint(g2,textFillCol,pageNumber, isPrinting);
                }else if(PdfDecoder.Helper!=null){
                  PdfDecoder.Helper.setPaint(g2, textFillCol, pageNumber, isPrinting);
                }else
                  g2.setPaint(textFillCol);

              }

              if((currentTR & GraphicsState.STROKE)==GraphicsState.STROKE){

                if(textStrokeCol!=null)
                  textStrokeCol.setScaling(cropX,cropH,scaling,0 ,0);

                if(customColorHandler !=null){
                  customColorHandler.setPaint(g2,textFillCol,pageNumber, isPrinting);
                }else if(PdfDecoder.Helper!=null){
                  PdfDecoder.Helper.setPaint(g2, textFillCol, pageNumber, isPrinting);
View Full Code Here

Examples of org.jpedal.color.PdfPaint

    public void drawText(float[][] Trm, String text, GraphicsState currentGraphicsState, float x, float y, Font javaFont) {

        /**
         * set color first
         */
        PdfPaint currentCol=null;

        if(Trm!=null){
            double[] nextAf=new double[]{Trm[0][0],Trm[0][1],Trm[1][0],Trm[1][1],Trm[2][0],Trm[2][1]};

            if((lastAf[0]==nextAf[0])&&(lastAf[1]==nextAf[1])&&
                    (lastAf[2]==nextAf[2])&&(lastAf[3]==nextAf[3])){
            }else{
                this.drawAffine(nextAf);
                lastAf[0]=nextAf[0];
                lastAf[1]=nextAf[1];
                lastAf[2]=nextAf[2];
                lastAf[3]=nextAf[3];
            }
        }

        int text_fill_type = currentGraphicsState.getTextRenderType();

        //for a fill
        if ((text_fill_type & GraphicsState.FILL) == GraphicsState.FILL) {
            currentCol=currentGraphicsState.getNonstrokeColor();

            if(currentCol.isPattern()){
                drawColor(currentCol,GraphicsState.FILL);
                resetTextColors=true;
            }else{

                int newCol=(currentCol).getRGB();
                if((resetTextColors)||((lastFillTextCol!=newCol))){
                    lastFillTextCol=newCol;
                    drawColor(currentCol,GraphicsState.FILL);
                }
            }
        }

        //and/or do a stroke
        if ((text_fill_type & GraphicsState.STROKE) == GraphicsState.STROKE){
            currentCol=currentGraphicsState.getStrokeColor();

            if(currentCol.isPattern()){
                drawColor(currentCol,GraphicsState.STROKE);
                resetTextColors=true;
            }else{

                int newCol=currentCol.getRGB();
                if((resetTextColors)||(lastStrokeCol!=newCol)){
                    lastStrokeCol=newCol;
                    drawColor(currentCol,GraphicsState.STROKE);
                }
            }
View Full Code Here

Examples of org.jpedal.color.PdfPaint

    /*save shape in array to draw*/
    public void drawShape(Shape currentShape,GraphicsState currentGraphicsState,int cmd) {

        int fillType=currentGraphicsState.getFillType();
        PdfPaint currentCol;

        int newCol;

        //check for 1 by 1 complex shape and replace with dot
        if(currentShape.getBounds().getWidth()==1 &&
                currentShape.getBounds().getHeight()==1 && currentGraphicsState.getLineWidth()<1)
            currentShape=new Rectangle(currentShape.getBounds().x,currentShape.getBounds().y,1,1);

        //stroke and fill (do fill first so we don't overwrite Stroke)
        if (fillType == GraphicsState.FILL || fillType == GraphicsState.FILLSTROKE) {

            currentCol=currentGraphicsState.getNonstrokeColor();
            if(currentCol.isPattern()){

                drawFillColor(currentCol);
                fillSet=true;
            }else{
                newCol=currentCol.getRGB();
                if((!fillSet) || (lastFillCol!=newCol)){
                    lastFillCol=newCol;
                    drawFillColor(currentCol);
                    fillSet=true;
                }
View Full Code Here

Examples of org.jpedal.color.PdfPaint

                                 Object javaGlyph, int type, GraphicsState gs, AffineTransform at, String glyf, PdfFont currentFontData, float glyfWidth) {

        /**
         * set color first
         */
        PdfPaint currentCol;

        int text_fill_type = gs.getTextRenderType();

        //for a fill
        if ((text_fill_type & GraphicsState.FILL) == GraphicsState.FILL) {
            currentCol= gs.getNonstrokeColor();

            if(currentCol.isPattern()){
                drawColor(currentCol,GraphicsState.FILL);
                resetTextColors=true;
            }else{

                int newCol=(currentCol).getRGB();
                if((resetTextColors)||((lastFillTextCol!=newCol))){
                    lastFillTextCol=newCol;
                    drawColor(currentCol,GraphicsState.FILL);
                    resetTextColors=false;
                }
            }
        }

        //and/or do a stroke
        if ((text_fill_type & GraphicsState.STROKE) == GraphicsState.STROKE){
            currentCol= gs.getStrokeColor();

            if(currentCol.isPattern()){
                drawColor(currentCol,GraphicsState.STROKE);
                resetTextColors=true;
            }else{
                int newCol=currentCol.getRGB();
                if((resetTextColors)||(lastStrokeCol!=newCol)){
                    resetTextColors=false;
                    lastStrokeCol=newCol;
                    drawColor(currentCol,GraphicsState.STROKE);
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.