Class 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 Detail

      • pageSize

        protected java.awt.Dimension pageSize
        Size of the page.
      • page

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

      • PageDrawer

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

      • drawPage

        public void drawPage​(java.awt.Graphics g,
                             PDPage p,
                             java.awt.Dimension pageDimension)
                      throws java.io.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:
        java.io.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 java.awt.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 java.awt.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 java.awt.geom.GeneralPath getLinePath()
        Get the current line path to be drawn.
        Returns:
        The current line path to be drawn.
      • setLinePath

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

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

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

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

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

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

        public java.awt.geom.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​(java.awt.Image awtImage,
                              java.awt.geom.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 java.io.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:
        java.io.IOException - If there is an IO error while shade-filling the path/clipping area.
      • shFill

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

        protected void SHFill_Function​(PDShading Shading)
                                throws java.io.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:
        java.io.IOException - If there is an IO error while shade-filling the path/clipping area.
      • SHFill_Axial

        protected void SHFill_Axial​(PDShading Shading)
                             throws java.io.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:
        java.io.IOException - If there is an IO error while shade-filling the path/clipping area.
      • SHFill_Radial

        protected void SHFill_Radial​(PDShading Shading)
                              throws java.io.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:
        java.io.IOException - If there is an IO error while shade-filling the path/clipping area.
      • SHFill_FreeGourad

        protected void SHFill_FreeGourad​(PDShading Shading)
                                  throws java.io.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:
        java.io.IOException - If there is an IO error while shade-filling the path/clipping area.
      • SHFill_LatticeGourad

        protected void SHFill_LatticeGourad​(PDShading Shading)
                                     throws java.io.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:
        java.io.IOException - If there is an IO error while shade-filling the path/clipping area.
      • SHFill_CoonsPatch

        protected void SHFill_CoonsPatch​(PDShading Shading)
                                  throws java.io.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:
        java.io.IOException - If there is an IO error while shade-filling the path/clipping area.
      • SHFill_TensorPatch

        protected void SHFill_TensorPatch​(PDShading Shading)
                                   throws java.io.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:
        java.io.IOException - If there is an IO error while shade-filling the path/clipping area.