Class CustomGraphicsStreamEngine

java.lang.Object
org.apache.pdfbox.contentstream.PDFStreamEngine
org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
org.apache.pdfbox.examples.rendering.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

    Modifier and Type
    Method
    Description
    void
     
    void
    clip(int windingRule)
     
    void
     
    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
     
    void
    fillAndStrokePath(int windingRule)
     
    void
    fillPath(int windingRule)
     
     
    void
    lineTo(float x, float y)
     
    static void
    main(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
     

    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 Details

    • CustomGraphicsStreamEngine

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

    • main

      public static void main(String[] args) throws IOException
      Throws:
      IOException
    • run

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      public void showTextStrings(org.apache.pdfbox.cos.COSArray array) throws IOException
      Overridden from PDFStreamEngine.
      Overrides:
      showTextStrings in class org.apache.pdfbox.contentstream.PDFStreamEngine
      Throws:
      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 IOException
      Overridden from PDFStreamEngine.
      Overrides:
      showGlyph in class org.apache.pdfbox.contentstream.PDFStreamEngine
      Throws:
      IOException