Class PageDrawer


  • public class PageDrawer
    extends PDFGraphicsStreamEngine
    Paints a page in a PDF document to a Canvas context. May be subclassed to provide custom rendering.

    If you want to do custom graphics processing rather than Canvas rendering, then you should subclass PDFGraphicsStreamEngine instead. Subclassing PageDrawer is only suitable for cases where the goal is to render onto a Canvas surface.

    • Constructor Detail

      • PageDrawer

        public PageDrawer​(PageDrawerParameters parameters)
                   throws IOException
        Constructor.
        Parameters:
        parameters - Parameters for page drawing.
        Throws:
        IOException - If there is an error loading properties from the file.
    • Method Detail

      • getRenderer

        public final PDFRenderer getRenderer()
        Returns the parent renderer.
      • getCanvas

        protected final android.graphics.Canvas getCanvas()
        Returns the underlying Canvas. May be null if drawPage has not yet been called.
      • getLinePath

        protected final android.graphics.Path getLinePath()
        Returns the current line path. This is reset to empty after each fill/stroke.
      • drawPage

        public void drawPage​(android.graphics.Paint p,
                             android.graphics.Canvas c,
                             PDRectangle pageSize)
                      throws IOException
        Draws the page to the requested canvas.
        Parameters:
        p - The paint.
        c - The canvas to draw onto.
        pageSize - The size of the page to draw.
        Throws:
        IOException - If there is an IO error while drawing the page.
      • beginText

        public void beginText()
                       throws IOException
        Description copied from class: PDFStreamEngine
        Called when the BT operator is encountered. This method is for overriding in subclasses, the default implementation does nothing.
        Overrides:
        beginText in class PDFStreamEngine
        Throws:
        IOException - if there was an error processing the text
      • endText

        public void endText()
                     throws IOException
        Description copied from class: PDFStreamEngine
        Called when the ET operator is encountered. This method is for overriding in subclasses, the default implementation does nothing.
        Overrides:
        endText in class PDFStreamEngine
        Throws:
        IOException - if there was an error processing the text
      • showFontGlyph

        protected void showFontGlyph​(Matrix textRenderingMatrix,
                                     PDFont font,
                                     int code,
                                     String unicode,
                                     Vector displacement)
                              throws IOException
        Description copied from class: PDFStreamEngine
        Called when a glyph is to be processed.This method is intended for overriding in subclasses, the default implementation does nothing.
        Overrides:
        showFontGlyph in class PDFStreamEngine
        Parameters:
        textRenderingMatrix - the current text rendering matrix, Trm
        font - the current font
        code - internal PDF character code for the glyph
        unicode - the Unicode text for this glyph, or null if the PDF does provide it
        displacement - the displacement (i.e. advance) of the glyph in text space
        Throws:
        IOException - if the glyph cannot be processed
      • appendRectangle

        public void appendRectangle​(android.graphics.PointF p0,
                                    android.graphics.PointF p1,
                                    android.graphics.PointF p2,
                                    android.graphics.PointF p3)
        Description copied from class: PDFGraphicsStreamEngine
        Append a rectangle to the current path.
        Specified by:
        appendRectangle in class PDFGraphicsStreamEngine
      • fillAndStrokePath

        public void fillAndStrokePath​(android.graphics.Path.FillType windingRule)
                               throws IOException
        Fills and then strokes the path.
        Specified by:
        fillAndStrokePath in class PDFGraphicsStreamEngine
        Parameters:
        windingRule - The winding rule this path will use.
        Throws:
        IOException - If there is an IO error while filling the path.
      • clip

        public void clip​(android.graphics.Path.FillType windingRule)
        Description copied from class: PDFGraphicsStreamEngine
        Modify the current clipping path by intersecting it with the current path. The clipping path will not be updated until the succeeding painting operator is called.
        Specified by:
        clip in class PDFGraphicsStreamEngine
        Parameters:
        windingRule - The winding rule which will be used for clipping.
      • curveTo

        public void curveTo​(float x1,
                            float y1,
                            float x2,
                            float y2,
                            float x3,
                            float y3)
        Description copied from class: PDFGraphicsStreamEngine
        Draws a curve from the current point to (x3,y3) using (x1,y1) and (x2,y2) as control points.
        Specified by:
        curveTo in class PDFGraphicsStreamEngine