Class PageDrawer

java.lang.Object
org.apache.pdfbox.util.PDFStreamEngine
org.apache.pdfbox.pdfviewer.PageDrawer

public class PageDrawer extends PDFStreamEngine
This will paint a page in a PDF document to a graphics context.
Version:
$Revision: 1.22 $
Author:
Ben Litchfield
  • Field Details

    • pageSize

      protected Dimension pageSize
      Size of the page.
    • page

      protected PDPage page
      Current page to be rendered.
  • Constructor Details

    • PageDrawer

      public PageDrawer() throws IOException
      Default constructor, loads properties from file.
      Throws:
      IOException - If there is an error loading properties from the file.
  • Method Details

    • drawPage

      public void drawPage(Graphics g, PDPage p, Dimension pageDimension) throws IOException
      This will draw the page to the requested context.
      Parameters:
      g - The graphics context to draw onto.
      p - The page to draw.
      pageDimension - The size of the page to draw.
      Throws:
      IOException - If there is an IO error while drawing the page.
    • dispose

      public void dispose()
      Remove all cached resources.
    • processTextPosition

      protected void processTextPosition(TextPosition text)
      You should override this method if you want to perform an action when a text is being processed.
      Overrides:
      processTextPosition in class PDFStreamEngine
      Parameters:
      text - The text to process
    • getGraphics

      public Graphics2D getGraphics()
      Get the graphics that we are currently drawing on.
      Returns:
      The graphics we are drawing on.
    • getPage

      public PDPage getPage()
      Get the page that is currently being drawn.
      Returns:
      The page that is being drawn.
    • getPageSize

      public Dimension getPageSize()
      Get the size of the page that is currently being drawn.
      Returns:
      The size of the page that is being drawn.
    • fixY

      public double fixY(double y)
      Fix the y coordinate.
      Parameters:
      y - The y coordinate.
      Returns:
      The updated y coordinate.
    • getLinePath

      public GeneralPath getLinePath()
      Get the current line path to be drawn.
      Returns:
      The current line path to be drawn.
    • setLinePath

      public void setLinePath(GeneralPath newLinePath)
      Set the line path to draw.
      Parameters:
      newLinePath - Set the line path to draw.
    • fillPath

      public void fillPath(int windingRule) throws IOException
      Fill the path.
      Parameters:
      windingRule - The winding rule this path will use.
      Throws:
      IOException - If there is an IO error while filling the path.
    • setStroke

      public void setStroke(BasicStroke newStroke)
      This will set the current stroke.
      Parameters:
      newStroke - The current stroke.
    • getStroke

      public BasicStroke getStroke()
      This will return the current stroke.
      Returns:
      The current stroke.
    • strokePath

      public void strokePath() throws IOException
      Stroke the path.
      Throws:
      IOException - If there is an IO error while stroking the path.
    • colorChanged

      @Deprecated public void colorChanged(boolean bStroking) throws IOException
      Deprecated.
      Called when the color changed.
      Parameters:
      bStroking - true for the stroking color, false for the non-stroking color
      Throws:
      IOException - if an I/O error occurs
    • transformedPoint

      public Point2D.Double transformedPoint(double x, double y)
      use the current transformation matrix to transform a single point.
      Parameters:
      x - x-coordinate of the point to be transform
      y - y-coordinate of the point to be transform
      Returns:
      the transformed coordinates as Point2D.Double
    • setClippingPath

      public void setClippingPath(int windingRule)
      Deprecated.
      Set the clipping Path.
      Parameters:
      windingRule - The winding rule this path will use.
    • setClippingWindingRule

      public void setClippingWindingRule(int windingRule)
      Set the clipping winding rule.
      Parameters:
      windingRule - The winding rule which will be used for clipping.
    • endPath

      public void endPath()
      Set the clipping Path.
    • drawImage

      public void drawImage(Image awtImage, AffineTransform at)
      Draw the AWT image. Called by Invoke. Moved into PageDrawer so that Invoke doesn't have to reach in here for Graphics as that breaks extensibility.
      Parameters:
      awtImage - The image to draw.
      at - The transformation to use when drawing.
    • SHFill

      public void SHFill(COSName ShadingName) throws IOException
      Deprecated.
      use shFill(COSName) instead.
      Fill with Shading. Called by SHFill operator.
      Parameters:
      ShadingName - The name of the Shading Dictionary to use for this fill instruction.
      Throws:
      IOException - If there is an IO error while shade-filling the path/clipping area.
    • shFill

      public void shFill(COSName shadingName) throws IOException
      Fill with Shading. Called by SHFill operator.
      Parameters:
      shadingName - The name of the Shading Dictionary to use for this fill instruction.
      Throws:
      IOException - If there is an IO error while shade-filling the clipping area.
    • SHFill_Function

      protected void SHFill_Function(PDShading Shading) throws IOException
      Fill with a Function-based gradient / shading. If extending the class, override this and its siblings, not the public SHFill method.
      Parameters:
      Shading - The Shading Dictionary to use for this fill instruction.
      Throws:
      IOException - If there is an IO error while shade-filling the path/clipping area.
    • SHFill_Axial

      protected void SHFill_Axial(PDShading Shading) throws IOException
      Fill with an Axial Shading. If extending the class, override this and its siblings, not the public SHFill method.
      Parameters:
      Shading - The Shading Dictionary to use for this fill instruction.
      Throws:
      IOException - If there is an IO error while shade-filling the path/clipping area.
    • SHFill_Radial

      protected void SHFill_Radial(PDShading Shading) throws IOException
      Fill with a Radial gradient / shading. If extending the class, override this and its siblings, not the public SHFill method.
      Parameters:
      Shading - The Shading Dictionary to use for this fill instruction.
      Throws:
      IOException - If there is an IO error while shade-filling the path/clipping area.
    • SHFill_FreeGourad

      protected void SHFill_FreeGourad(PDShading Shading) throws IOException
      Fill with a Free-form Gourad-shaded triangle mesh. If extending the class, override this and its siblings, not the public SHFill method.
      Parameters:
      Shading - The Shading Dictionary to use for this fill instruction.
      Throws:
      IOException - If there is an IO error while shade-filling the path/clipping area.
    • SHFill_LatticeGourad

      protected void SHFill_LatticeGourad(PDShading Shading) throws IOException
      Fill with a Lattice-form Gourad-shaded triangle mesh. If extending the class, override this and its siblings, not the public SHFill method.
      Parameters:
      Shading - The Shading Dictionary to use for this fill instruction.
      Throws:
      IOException - If there is an IO error while shade-filling the path/clipping area.
    • SHFill_CoonsPatch

      protected void SHFill_CoonsPatch(PDShading Shading) throws IOException
      Fill with a Coons patch mesh If extending the class, override this and its siblings, not the public SHFill method.
      Parameters:
      Shading - The Shading Dictionary to use for this fill instruction.
      Throws:
      IOException - If there is an IO error while shade-filling the path/clipping area.
    • SHFill_TensorPatch

      protected void SHFill_TensorPatch(PDShading Shading) throws IOException
      Fill with a Tensor-product patch mesh. If extending the class, override this and its siblings, not the public SHFill method.
      Parameters:
      Shading - The Shading Dictionary to use for this fill instruction.
      Throws:
      IOException - If there is an IO error while shade-filling the path/clipping area.