Class PdfBoxSlowOutputDevice

java.lang.Object
com.openhtmltopdf.render.AbstractOutputDevice
com.openhtmltopdf.pdfboxout.PdfBoxSlowOutputDevice
All Implemented Interfaces:
com.openhtmltopdf.extend.OutputDevice, PdfBoxOutputDevice

public class PdfBoxSlowOutputDevice
extends com.openhtmltopdf.render.AbstractOutputDevice
implements com.openhtmltopdf.extend.OutputDevice, PdfBoxOutputDevice
  • Constructor Details

    • PdfBoxSlowOutputDevice

      public PdfBoxSlowOutputDevice​(float dotsPerPoint, boolean testMode)
  • Method Details

    • setWriter

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

      public org.apache.pdfbox.pdmodel.PDDocument getWriter()
      Specified by:
      getWriter 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
    • finishPage

      public void finishPage()
      Specified by:
      finishPage 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
    • getRenderingHint

      public Object getRenderingHint​(RenderingHints.Key key)
      Specified by:
      getRenderingHint in interface com.openhtmltopdf.extend.OutputDevice
      Specified by:
      getRenderingHint in interface PdfBoxOutputDevice
    • setRenderingHint

      public void setRenderingHint​(RenderingHints.Key key, Object value)
      Specified by:
      setRenderingHint in interface com.openhtmltopdf.extend.OutputDevice
      Specified by:
      setRenderingHint 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
    • drawStringFast

      public void drawStringFast​(String s, float x, float y, com.openhtmltopdf.render.JustificationInfo info, PdfBoxFontResolver.FontDescription desc, float fontSize)
      Specified by:
      drawStringFast in interface PdfBoxOutputDevice
    • getCurrentPage

      public PdfContentStreamAdapter getCurrentPage()
      Specified by:
      getCurrentPage in interface PdfBoxOutputDevice
    • getPage

      public org.apache.pdfbox.pdmodel.PDPage getPage()
      Specified by:
      getPage 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
    • realizeImage

      public void realizeImage​(PdfBoxImage img)
      Specified by:
      realizeImage 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 _src, Rectangle contentBounds, float intrinsicWidth, float intrinsicHeight)
      Specified by:
      drawPdfAsImage in interface PdfBoxOutputDevice
    • getDotsPerPoint

      public float getDotsPerPoint()
      Specified by:
      getDotsPerPoint in interface PdfBoxOutputDevice
    • start

      public void start​(Document doc)
      Specified by:
      start in interface PdfBoxOutputDevice
    • finish

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

      public int getPageRefY​(com.openhtmltopdf.render.Box box)
      Specified by:
      getPageRefY 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
    • getSharedContext

      public com.openhtmltopdf.layout.SharedContext getSharedContext()
      Specified by:
      getSharedContext in interface PdfBoxOutputDevice
    • 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
    • getStartPageNo

      public int getStartPageNo()
      Specified by:
      getStartPageNo in interface PdfBoxOutputDevice
    • setStartPageNo

      public void setStartPageNo​(int startPageNo)
      Specified by:
      setStartPageNo 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
    • findPagePositionsByID

      public List<PagePosition> findPagePositionsByID​(com.openhtmltopdf.css.style.CssContext c, Pattern pattern)
      Specified by:
      findPagePositionsByID in interface PdfBoxOutputDevice
    • setRenderingContext

      public void setRenderingContext​(com.openhtmltopdf.render.RenderingContext result)
      Specified by:
      setRenderingContext in interface PdfBoxOutputDevice
    • setBidiReorderer

      public void setBidiReorderer​(com.openhtmltopdf.bidi.BidiReorderer reorderer)
      Specified by:
      setBidiReorderer in interface PdfBoxOutputDevice
    • popTransforms

      public void popTransforms​(List<AffineTransform> inverse)
      Specified by:
      popTransforms in interface com.openhtmltopdf.extend.OutputDevice
      Specified by:
      popTransforms in interface PdfBoxOutputDevice
    • pushTransforms

      public List<AffineTransform> pushTransforms​(List<AffineTransform> transforms)
      Specified by:
      pushTransforms in interface com.openhtmltopdf.extend.OutputDevice
      Specified by:
      pushTransforms 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
    • pushTransformLayer

      public void pushTransformLayer​(AffineTransform transform)
      Specified by:
      pushTransformLayer in interface com.openhtmltopdf.extend.OutputDevice
      Specified by:
      pushTransformLayer 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