Class CustomGraphicsStreamEngine


  • public class CustomGraphicsStreamEngine
    extends org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
    Example of a custom PDFGraphicsStreamEngine subclass. Allows text and graphics to be processed in a custom manner. This example simply prints the operations to stdout.

    See PDFStreamEngine for further methods which may be overridden.

    Author:
    John Hewson
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected CustomGraphicsStreamEngine​(org.apache.pdfbox.pdmodel.PDPage page)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void appendRectangle​(java.awt.geom.Point2D p0, java.awt.geom.Point2D p1, java.awt.geom.Point2D p2, java.awt.geom.Point2D p3)  
      void clip​(int windingRule)  
      void closePath()  
      void curveTo​(float x1, float y1, float x2, float y2, float x3, float y3)  
      void drawImage​(org.apache.pdfbox.pdmodel.graphics.image.PDImage pdImage)  
      void endPath()  
      void fillAndStrokePath​(int windingRule)  
      void fillPath​(int windingRule)  
      java.awt.geom.Point2D getCurrentPoint()  
      void lineTo​(float x, float y)  
      static void main​(java.lang.String[] args)  
      void moveTo​(float x, float y)  
      void run()
      Runs the engine on the current page.
      void shadingFill​(org.apache.pdfbox.cos.COSName shadingName)  
      protected void showGlyph​(org.apache.pdfbox.util.Matrix textRenderingMatrix, org.apache.pdfbox.pdmodel.font.PDFont font, int code, org.apache.pdfbox.util.Vector displacement)
      Overridden from PDFStreamEngine.
      void showTextString​(byte[] string)
      Overridden from PDFStreamEngine.
      void showTextStrings​(org.apache.pdfbox.cos.COSArray array)
      Overridden from PDFStreamEngine.
      void strokePath()  
      • Methods inherited from class org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine

        getPage
      • Methods inherited from class org.apache.pdfbox.contentstream.PDFStreamEngine

        addOperator, applyTextAdjustment, beginMarkedContentSequence, beginText, decreaseLevel, endMarkedContentSequence, endText, getAppearance, getCurrentPage, getGraphicsStackSize, getGraphicsState, getInitialMatrix, getLevel, getResources, getTextLineMatrix, getTextMatrix, increaseLevel, isShouldProcessColorOperators, markedContentPoint, operatorException, processAnnotation, processChildStream, processOperator, processOperator, processPage, processSoftMask, processTilingPattern, processTilingPattern, processTransparencyGroup, processType3Stream, restoreGraphicsStack, restoreGraphicsState, saveGraphicsStack, saveGraphicsState, setLineDashPattern, setTextLineMatrix, setTextMatrix, showAnnotation, showFontGlyph, showForm, showText, showTransparencyGroup, showType3Glyph, transformedPoint, transformWidth, unsupportedOperator
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CustomGraphicsStreamEngine

        protected CustomGraphicsStreamEngine​(org.apache.pdfbox.pdmodel.PDPage page)
        Constructor.
        Parameters:
        page - PDF Page
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • run

        public void run()
                 throws java.io.IOException
        Runs the engine on the current page.
        Throws:
        java.io.IOException - If there is an IO error while drawing the page.
      • appendRectangle

        public void appendRectangle​(java.awt.geom.Point2D p0,
                                    java.awt.geom.Point2D p1,
                                    java.awt.geom.Point2D p2,
                                    java.awt.geom.Point2D p3)
                             throws java.io.IOException
        Specified by:
        appendRectangle in class org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
        Throws:
        java.io.IOException
      • drawImage

        public void drawImage​(org.apache.pdfbox.pdmodel.graphics.image.PDImage pdImage)
                       throws java.io.IOException
        Specified by:
        drawImage in class org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
        Throws:
        java.io.IOException
      • clip

        public void clip​(int windingRule)
                  throws java.io.IOException
        Specified by:
        clip in class org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
        Throws:
        java.io.IOException
      • moveTo

        public void moveTo​(float x,
                           float y)
                    throws java.io.IOException
        Specified by:
        moveTo in class org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
        Throws:
        java.io.IOException
      • lineTo

        public void lineTo​(float x,
                           float y)
                    throws java.io.IOException
        Specified by:
        lineTo in class org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
        Throws:
        java.io.IOException
      • curveTo

        public void curveTo​(float x1,
                            float y1,
                            float x2,
                            float y2,
                            float x3,
                            float y3)
                     throws java.io.IOException
        Specified by:
        curveTo in class org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
        Throws:
        java.io.IOException
      • getCurrentPoint

        public java.awt.geom.Point2D getCurrentPoint()
                                              throws java.io.IOException
        Specified by:
        getCurrentPoint in class org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
        Throws:
        java.io.IOException
      • closePath

        public void closePath()
                       throws java.io.IOException
        Specified by:
        closePath in class org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
        Throws:
        java.io.IOException
      • endPath

        public void endPath()
                     throws java.io.IOException
        Specified by:
        endPath in class org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
        Throws:
        java.io.IOException
      • strokePath

        public void strokePath()
                        throws java.io.IOException
        Specified by:
        strokePath in class org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
        Throws:
        java.io.IOException
      • fillPath

        public void fillPath​(int windingRule)
                      throws java.io.IOException
        Specified by:
        fillPath in class org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
        Throws:
        java.io.IOException
      • fillAndStrokePath

        public void fillAndStrokePath​(int windingRule)
                               throws java.io.IOException
        Specified by:
        fillAndStrokePath in class org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
        Throws:
        java.io.IOException
      • shadingFill

        public void shadingFill​(org.apache.pdfbox.cos.COSName shadingName)
                         throws java.io.IOException
        Specified by:
        shadingFill in class org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
        Throws:
        java.io.IOException
      • showTextString

        public void showTextString​(byte[] string)
                            throws java.io.IOException
        Overridden from PDFStreamEngine.
        Overrides:
        showTextString in class org.apache.pdfbox.contentstream.PDFStreamEngine
        Throws:
        java.io.IOException
      • showTextStrings

        public void showTextStrings​(org.apache.pdfbox.cos.COSArray array)
                             throws java.io.IOException
        Overridden from PDFStreamEngine.
        Overrides:
        showTextStrings in class org.apache.pdfbox.contentstream.PDFStreamEngine
        Throws:
        java.io.IOException
      • showGlyph

        protected void showGlyph​(org.apache.pdfbox.util.Matrix textRenderingMatrix,
                                 org.apache.pdfbox.pdmodel.font.PDFont font,
                                 int code,
                                 org.apache.pdfbox.util.Vector displacement)
                          throws java.io.IOException
        Overridden from PDFStreamEngine.
        Overrides:
        showGlyph in class org.apache.pdfbox.contentstream.PDFStreamEngine
        Throws:
        java.io.IOException