Class PdfBoxFastOutputDevice

  • All Implemented Interfaces:
    com.openhtmltopdf.extend.OutputDevice, PdfBoxOutputDevice

    public class PdfBoxFastOutputDevice
    extends com.openhtmltopdf.render.AbstractOutputDevice
    implements com.openhtmltopdf.extend.OutputDevice, PdfBoxOutputDevice
    • Constructor Detail

      • PdfBoxFastOutputDevice

        public PdfBoxFastOutputDevice​(float dotsPerPoint,
                                      boolean testMode,
                                      boolean pdfUaConform,
                                      boolean pdfAConform)
    • Method Detail

      • setWriter

        public void setWriter​(org.apache.pdfbox.pdmodel.PDDocument writer)
        Specified by:
        setWriter in interface PdfBoxOutputDevice
      • initializePage

        public void initializePage​(org.apache.pdfbox.pdmodel.PDPageContentStream currentPage,
                                   org.apache.pdfbox.pdmodel.PDPage page,
                                   float height)
        Start a page. A new PDF page starts a new content stream so all graphics state has to be set back to default.
        Specified by:
        initializePage in interface PdfBoxOutputDevice
      • paintReplacedElement

        public void paintReplacedElement​(com.openhtmltopdf.render.RenderingContext c,
                                         com.openhtmltopdf.render.BlockBox box)
        Specified by:
        paintReplacedElement in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        paintReplacedElement in interface PdfBoxOutputDevice
      • paintBackground

        public void paintBackground​(com.openhtmltopdf.render.RenderingContext c,
                                    com.openhtmltopdf.render.Box box)
        We use paintBackground to do extra stuff such as processing links, forms and form controls.
        Specified by:
        paintBackground in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        paintBackground in interface PdfBoxOutputDevice
        Overrides:
        paintBackground in class com.openhtmltopdf.render.AbstractOutputDevice
      • getDeviceLength

        public float getDeviceLength​(float length)
        Given a value in dots units, converts to PDF points.
        Specified by:
        getDeviceLength in interface PdfBoxOutputDevice
      • drawBorderLine

        public void drawBorderLine​(Shape bounds,
                                   int side,
                                   int lineWidth,
                                   boolean solid)
        Specified by:
        drawBorderLine in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        drawBorderLine in interface PdfBoxOutputDevice
      • setColor

        public void setColor​(com.openhtmltopdf.css.parser.FSColor color)
        Specified by:
        setColor in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        setColor in interface PdfBoxOutputDevice
      • draw

        public void draw​(Shape s)
        Specified by:
        draw in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        draw in interface PdfBoxOutputDevice
      • drawLine

        protected void drawLine​(int x1,
                                int y1,
                                int x2,
                                int y2)
        Specified by:
        drawLine in class com.openhtmltopdf.render.AbstractOutputDevice
      • drawRect

        public void drawRect​(int x,
                             int y,
                             int width,
                             int height)
        Specified by:
        drawRect in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        drawRect in interface PdfBoxOutputDevice
      • drawOval

        public void drawOval​(int x,
                             int y,
                             int width,
                             int height)
        Specified by:
        drawOval in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        drawOval in interface PdfBoxOutputDevice
      • fill

        public void fill​(Shape s)
        Specified by:
        fill in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        fill in interface PdfBoxOutputDevice
      • fillRect

        public void fillRect​(int x,
                             int y,
                             int width,
                             int height)
        Specified by:
        fillRect in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        fillRect in interface PdfBoxOutputDevice
      • fillOval

        public void fillOval​(int x,
                             int y,
                             int width,
                             int height)
        Specified by:
        fillOval in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        fillOval in interface PdfBoxOutputDevice
      • translate

        public void translate​(double tx,
                              double ty)
        Specified by:
        translate in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        translate in interface PdfBoxOutputDevice
      • setFont

        public void setFont​(com.openhtmltopdf.render.FSFont font)
        Specified by:
        setFont in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        setFont in interface PdfBoxOutputDevice
      • drawString

        public void drawString​(String s,
                               float x,
                               float y,
                               com.openhtmltopdf.render.JustificationInfo info)
        Specified by:
        drawString in interface PdfBoxOutputDevice
      • normalizeY

        public float normalizeY​(float y,
                                float pageHeight)
        Converts a top down unit to a bottom up PDF unit for the specified page height.
        Specified by:
        normalizeY in interface PdfBoxOutputDevice
      • setStroke

        public void setStroke​(Stroke s)
        Specified by:
        setStroke in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        setStroke in interface PdfBoxOutputDevice
      • clip

        public void clip​(Shape s)
        Specified by:
        clip in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        clip in interface PdfBoxOutputDevice
      • getClip

        public Shape getClip()
        Specified by:
        getClip in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        getClip in interface PdfBoxOutputDevice
      • popClip

        public void popClip()
        Specified by:
        popClip in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        popClip in interface PdfBoxOutputDevice
      • pushClip

        public void pushClip​(Shape s)
        Specified by:
        pushClip in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        pushClip in interface PdfBoxOutputDevice
      • setClip

        public void setClip​(Shape s)
        Specified by:
        setClip in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        setClip in interface PdfBoxOutputDevice
      • getStroke

        public Stroke getStroke()
        Specified by:
        getStroke in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        getStroke in interface PdfBoxOutputDevice
      • drawImage

        public void drawImage​(com.openhtmltopdf.extend.FSImage fsImage,
                              int x,
                              int y,
                              boolean interpolate)
        Specified by:
        drawImage in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        drawImage in interface PdfBoxOutputDevice
      • drawPdfAsImage

        public void drawPdfAsImage​(org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject _srcObject,
                                   Rectangle contentBounds,
                                   float intrinsicWidth,
                                   float intrinsicHeight)
        Specified by:
        drawPdfAsImage in interface PdfBoxOutputDevice
      • finish

        public void finish​(com.openhtmltopdf.render.RenderingContext c,
                           com.openhtmltopdf.render.Box root)
        Specified by:
        finish in interface PdfBoxOutputDevice
      • addMetadata

        public void addMetadata​(String name,
                                String value)
        Appends a name/content metadata pair to this output device. A name or content value of null will be ignored.
        Specified by:
        addMetadata in interface PdfBoxOutputDevice
        Parameters:
        name - the name of the metadata element to add.
      • getMetadataByName

        public String getMetadataByName​(String name)
        Searches the metadata name/content pairs of the current document and returns the content value from the first pair with a matching name. The search is case insensitive.
        Specified by:
        getMetadataByName in interface PdfBoxOutputDevice
        Parameters:
        name - the metadata element name to locate.
        Returns:
        the content value of the first found metadata element; otherwise null.
      • getMetadataListByName

        public List<String> getMetadataListByName​(String name)
        Searches the metadata name/content pairs of the current document and returns any content values with a matching name in an ArrayList. The search is case insensitive.
        Specified by:
        getMetadataListByName in interface PdfBoxOutputDevice
        Parameters:
        name - the metadata element name to locate.
        Returns:
        an ArrayList with matching content values; otherwise an empty list.
      • setMetadata

        public void setMetadata​(String name,
                                String value)
        Replaces all copies of the named metadata with a single value. A a new value of null will result in the removal of all copies of the named metadata. Use addMetadata to append additional values with the same name.
        Specified by:
        setMetadata in interface PdfBoxOutputDevice
        Parameters:
        name - the metadata element name to locate.
      • getMetadata

        public List<com.openhtmltopdf.pdfboxout.PdfBoxSlowOutputDevice.Metadata> getMetadata()
        Specified by:
        getMetadata in interface PdfBoxOutputDevice
        Returns:
        All metadata entries
      • setSharedContext

        public void setSharedContext​(com.openhtmltopdf.layout.SharedContext sharedContext)
        Specified by:
        setSharedContext in interface PdfBoxOutputDevice
      • setRoot

        public void setRoot​(com.openhtmltopdf.render.Box root)
        Specified by:
        setRoot in interface PdfBoxOutputDevice
      • drawSelection

        public void drawSelection​(com.openhtmltopdf.render.RenderingContext c,
                                  com.openhtmltopdf.render.InlineText inlineText)
        Specified by:
        drawSelection in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        drawSelection in interface PdfBoxOutputDevice
      • isSupportsSelection

        public boolean isSupportsSelection()
        Specified by:
        isSupportsSelection in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        isSupportsSelection in interface PdfBoxOutputDevice
      • isSupportsCMYKColors

        public boolean isSupportsCMYKColors()
        Specified by:
        isSupportsCMYKColors in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        isSupportsCMYKColors in interface PdfBoxOutputDevice
      • drawWithGraphics

        public void drawWithGraphics​(float x,
                                     float y,
                                     float width,
                                     float height,
                                     com.openhtmltopdf.extend.OutputDeviceGraphicsDrawer renderer)
        Specified by:
        drawWithGraphics in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        drawWithGraphics in interface PdfBoxOutputDevice
      • getAbsoluteTransformOriginX

        public float getAbsoluteTransformOriginX()
        Specified by:
        getAbsoluteTransformOriginX in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        getAbsoluteTransformOriginX in interface PdfBoxOutputDevice
      • getAbsoluteTransformOriginY

        public float getAbsoluteTransformOriginY()
        Specified by:
        getAbsoluteTransformOriginY in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        getAbsoluteTransformOriginY in interface PdfBoxOutputDevice
      • setPaint

        public void setPaint​(Paint paint)
        Specified by:
        setPaint in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        setPaint in interface PdfBoxOutputDevice
      • isPDF

        public boolean isPDF()
        Specified by:
        isPDF in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        isPDF in interface PdfBoxOutputDevice
        Overrides:
        isPDF in class com.openhtmltopdf.render.AbstractOutputDevice
      • close

        public void close()
        Perform any internal cleanup needed
        Specified by:
        close in interface PdfBoxOutputDevice
      • popTransformLayer

        public void popTransformLayer()
        Specified by:
        popTransformLayer in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        popTransformLayer in interface PdfBoxOutputDevice
      • isFastRenderer

        public boolean isFastRenderer()
        Specified by:
        isFastRenderer in interface com.openhtmltopdf.extend.OutputDevice
        Specified by:
        isFastRenderer in interface PdfBoxOutputDevice
      • startStructure

        public Object startStructure​(com.openhtmltopdf.extend.StructureType type,
                                     com.openhtmltopdf.render.Box box)
        Specified by:
        startStructure in interface com.openhtmltopdf.extend.OutputDevice
      • endStructure

        public void endStructure​(Object token)
        Specified by:
        endStructure in interface com.openhtmltopdf.extend.OutputDevice