Top Inners Fields Constructors Methods
com.openhtmltopdf.pdfboxout

public Class PdfBoxRenderer

extends Object
implements Closeable, PageSupplier
Class Inheritance
All Implemented Interfaces
com.openhtmltopdf.pdfboxout.PageSupplier, java.io.Closeable, java.lang.AutoCloseable
Imports
com.openhtmltopdf.bidi.BidiReorderer, .BidiSplitter, .BidiSplitterFactory, .SimpleBidiReorderer, com.openhtmltopdf.context.StyleReference, com.openhtmltopdf.css.constants.IdentValue, com.openhtmltopdf.css.style.CalculatedStyle, com.openhtmltopdf.extend.*, .FSDOMMutator, com.openhtmltopdf.layout.BoxBuilder, .Layer, .LayoutContext, .SharedContext, com.openhtmltopdf.outputdevice.helper.BaseDocument, .ExternalResourceControlPriority, .ExternalResourceType, .PageDimensions, .UnicodeImplementation, com.openhtmltopdf.pdfboxout.PdfBoxSlowOutputDevice.Metadata, .PdfRendererBuilder.CacheStore, .PdfRendererBuilder.PdfAConformance, com.openhtmltopdf.render.BlockBox, .Box, .PageBox, .RenderingContext, .ViewportBox, com.openhtmltopdf.render.displaylist.DisplayListCollector, .DisplayListContainer, .DisplayListPainter, .PagedBoxCollector, .DisplayListContainer.DisplayListPageContainer, com.openhtmltopdf.resource.XMLResource, com.openhtmltopdf.simple.extend.XhtmlNamespaceHandler, com.openhtmltopdf.util.LogMessageId, .ThreadCtx, .XRLog, org.apache.pdfbox.cos.COSDictionary, org.apache.pdfbox.pdmodel.*, .PDPageContentStream.AppendMode, org.apache.pdfbox.pdmodel.common.PDMetadata, .PDRectangle, org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDMarkInfo, org.apache.pdfbox.pdmodel.encryption.PDEncryption, org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent, org.apache.pdfbox.pdmodel.interactive.viewerpreferences.PDViewerPreferences, org.apache.xmpbox.XMPMetadata, org.apache.xmpbox.schema.*, org.apache.xmpbox.type.BadFieldValueException, org.apache.xmpbox.xml.XmpSerializer, org.w3c.dom.Document, .Element, .Node, org.xml.sax.InputSource, javax.xml.transform.*, javax.xml.transform.dom.DOMSource, javax.xml.transform.stream.StreamResult, java.awt.*, java.awt.geom.Rectangle2D, java.io.*, java.nio.charset.StandardCharsets, java.util.ArrayList, .Arrays, .Calendar, .Collections, .Comparator, .List, java.util.logging.Level, java.util.regex.Pattern, java.util.stream.Collectors, .IntStream

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private byte[]
private byte
private Document
private final List<FSDOMMutator>
private final float
private final int
private PDFCreationListener
private SVGDrawer
private OutputStream
private final PdfBoxOutputDevice
private PageSupplier
private PdfRendererBuilder.PdfAConformance
private PDDocument
private PDEncryption
private boolean
private float
private String
private BidiReorderer
private BlockBox
private final SharedContext
private BidiSplitterFactory
private SVGDrawer
private boolean
private final boolean
private static final int
private static final float
private static final int
private final Closeable
private final Comparator<PagePosition<?>>
PAGE_POSITION_COMPARATOR

Start page to end page and then top to bottom on page.

Constructor Summary

AccessConstructor and Description
pack-priv
PdfBoxRenderer(BaseDocument doc, UnicodeImplementation unicode, PageDimensions pageSize, PdfRendererBuilderState state, Closeable diagnosticConsumer)

This method is constantly changing as options are added to the builder.

Method Summary

Modifier and TypeMethod and Description
private void
addPdfASchema(PDDocument document, PdfRendererBuilder.PdfAConformance pdfAConformance, boolean isPdfUa)

public void
cleanup()
Deprecated Use close instead.

public void
close()

Implements java.io.Closeable.close.

Cleanup thread resources.

private <T> PagePosition<T>
createPagePosition(String id, T element, int pageNo, float x, float y, float w, float h)

public void
createPDF()

Creates a PDF with setup specified by builder.

public void
createPDF(OutputStream os)
Deprecated Use builder to set output stream.

public void
createPDF(OutputStream os, boolean finish)
Deprecated Use builder to set output stream.

public void
createPDF(OutputStream os, boolean finish, int initialPageNo)
Deprecated Use builder to set output stream. NOTE: Caller is responsible for cleaning up the OutputStream.

private XMPSchema
createPdfaProperty(String category, String description, String name, String valueType)

private XMPSchema
createPdfaSchema(String schema, String namespace, String prefix, List<XMPSchema> properties)

private void
createPdfFast(boolean finish, int initialPageNo)

Go fast!

public void
createPDFWithoutClosing()

Creates a PDF with setup specified by builder.

private String
public void
exportText(Writer writer)
Deprecated unused and untested.

private int
findEndPage(RenderingContext c, Layer layer, List<PageBox> pages)

Returns the end page number for a layer.

public List<PagePosition<Box>>
private int
findStartPage(RenderingContext c, Layer layer, List<PageBox> pages)

Returns the start page for a layer.

public void
finishPDF()
Deprecated

private void
private void
private void
firePreWrite(int pageCount)

public Document
public float
private static Element
public PdfBoxFontResolver
getFontResolver()

Get the PDF-BOX font resolver.

private Rectangle
public float
getLastContentBottom()

Returns the bottom Y postion in bottom-up PDF units on the last page of content

Warning

NOT transform aware.

private List<PagePosition<Layer>>
public List<PagePosition<Layer>>
getLayerPositions(Layer layer)

Returns a list of page positions for a single layer.

public List<PagePosition<Layer>>
getLayersPositions()

Returns a list of page positions for all layers in the document.

public PDFCreationListener
public PdfBoxOutputDevice
public PDDocument
getPdfDocument()

Returns the PDDocument or null if it has been closed.

public float
public BlockBox
public SharedContext
public void
private Document
private LayoutContext
private RenderingContext
private void
private void
paintPageFast(RenderingContext c, PageBox page, DisplayListContainer.DisplayListPageContainer pageOperations, int additionalTranslateX)

public PDPage
requestPage(PDDocument
PDDocument the page belongs to
doc
,
float
Width of page in PDF points (1/72 inch)
pageWidth
,
float
Height of page in PDF points
pageHeight
,
int
Number of the layout page - this may differ from the PDF document page if there are previous shadow pages.
pageNumber
,
int
Number of the shadow-page or -1 if on a main page.
shadowPageNumber
)

Implements com.openhtmltopdf.pdfboxout.PageSupplier.requestPage.

Called whenever a page or shadow-page is needed.

private void
private void
private void
private void
private void
private void
public void
private String
public void
writeNextDocument()
Deprecated Doubt this still works as untested.

public void
writeNextDocument(int initialPageNo)
Deprecated Doubt this still works as untested.

private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_colorProfileback to summary
private byte[] _colorProfile
_defaultTextDirectionback to summary
private byte _defaultTextDirection
_docback to summary
private Document _doc
_domMutatorsback to summary
private final List<FSDOMMutator> _domMutators
_dotsPerPointback to summary
private final float _dotsPerPoint
_initialPageNumberback to summary
private final int _initialPageNumber
_listenerback to summary
private PDFCreationListener _listener
_mathmlImplback to summary
private SVGDrawer _mathmlImpl
_osback to summary
private OutputStream _os
_outputDeviceback to summary
private final PdfBoxOutputDevice _outputDevice
_pageSupplierback to summary
private PageSupplier _pageSupplier
_pdfAConformanceback to summary
private PdfRendererBuilder.PdfAConformance _pdfAConformance
_pdfDocback to summary
private PDDocument _pdfDoc
_pdfEncryptionback to summary
private PDEncryption _pdfEncryption
_pdfUaConformanceback to summary
private boolean _pdfUaConformance
_pdfVersionback to summary
private float _pdfVersion
_producerback to summary
private String _producer
_reordererback to summary
private BidiReorderer _reorderer
_rootback to summary
private BlockBox _root
_sharedContextback to summary
private final SharedContext _sharedContext
_splitterFactoryback to summary
private BidiSplitterFactory _splitterFactory
_svgImplback to summary
private SVGDrawer _svgImpl
_testModeback to summary
private boolean _testMode
_useFastModeback to summary
private final boolean _useFastMode
DEFAULT_DOTS_PER_PIXELback to summary
private static final int DEFAULT_DOTS_PER_PIXEL
DEFAULT_DOTS_PER_POINTback to summary
private static final float DEFAULT_DOTS_PER_POINT
DEFAULT_PDF_POINTS_PER_INCHback to summary
private static final int DEFAULT_PDF_POINTS_PER_INCH
diagnosticConsumerback to summary
private final Closeable diagnosticConsumer
PAGE_POSITION_COMPARATORback to summary
private final Comparator<PagePosition<?>> PAGE_POSITION_COMPARATOR

Start page to end page and then top to bottom on page.

Constructor Detail

PdfBoxRendererback to summary
pack-priv PdfBoxRenderer(BaseDocument doc, UnicodeImplementation unicode, PageDimensions pageSize, PdfRendererBuilderState state, Closeable diagnosticConsumer)

This method is constantly changing as options are added to the builder.

Method Detail

addPdfASchemaback to summary
private void addPdfASchema(PDDocument document, PdfRendererBuilder.PdfAConformance pdfAConformance, boolean isPdfUa)
cleanupback to summary
public void cleanup()

Deprecated

Use close instead.

Annotations
@Deprecated
closeback to summary
public void close()

Implements java.io.Closeable.close.

Cleanup thread resources. MUST be called after finishing with the renderer.

Annotations
@Override
createPagePositionback to summary
private <T> PagePosition<T> createPagePosition(String id, T element, int pageNo, float x, float y, float w, float h)
createPDFback to summary
public void createPDF() throws IOException

Creates a PDF with setup specified by builder. On finsihing or failing, saves (if successful) and closes the PDF document.

createPDFback to summary
public void createPDF(OutputStream os) throws IOException

Deprecated

Use builder to set output stream.

Annotations
@Deprecated
createPDFback to summary
public void createPDF(OutputStream os, boolean finish) throws IOException

Deprecated

Use builder to set output stream.

Annotations
@Deprecated
createPDFback to summary
public void createPDF(OutputStream os, boolean finish, int initialPageNo) throws IOException

Deprecated

Use builder to set output stream. NOTE: Caller is responsible for cleaning up the OutputStream.

Annotations
@Deprecated
createPdfaPropertyback to summary
private XMPSchema createPdfaProperty(String category, String description, String name, String valueType)
createPdfaSchemaback to summary
private XMPSchema createPdfaSchema(String schema, String namespace, String prefix, List<XMPSchema> properties)
createPdfFastback to summary
private void createPdfFast(boolean finish, int initialPageNo) throws IOException

Go fast!

createPDFWithoutClosingback to summary
public void createPDFWithoutClosing() throws IOException

Creates a PDF with setup specified by builder. On finsihing or failing, DOES NOT save or close the PDF document. Useful for post-processing the PDDocument which can be retrieved by getPdfDocument().

createXPacketback to summary
private String createXPacket(String metadata)
exportTextback to summary
public void exportText(Writer writer) throws IOException

Deprecated

unused and untested.

Annotations
@Deprecated
findEndPageback to summary
private int findEndPage(RenderingContext c, Layer layer, List<PageBox> pages)

Returns the end page number for a layer. Transform aware.

findPagePositionsByIDback to summary
public List<PagePosition<Box>> findPagePositionsByID(Pattern pattern)
findStartPageback to summary
private int findStartPage(RenderingContext c, Layer layer, List<PageBox> pages)

Returns the start page for a layer. Transform aware.

finishPDFback to summary
public void finishPDF() throws IOException

Deprecated

Annotations
@Deprecated
fireOnCloseback to summary
private void fireOnClose()
firePreOpenback to summary
private void firePreOpen()
firePreWriteback to summary
private void firePreWrite(int pageCount)
getDocumentback to summary
public Document getDocument()
getDotsPerPointback to summary
public float getDotsPerPoint()
getFirstChildElementback to summary
private static Element getFirstChildElement(Element element)
getFontResolverback to summary
public PdfBoxFontResolver getFontResolver()

Get the PDF-BOX font resolver. Can be used to add fonts in code.

getInitialExtentsback to summary
private Rectangle getInitialExtents(LayoutContext c)
getLastContentBottomback to summary
public float getLastContentBottom()

Returns the bottom Y postion in bottom-up PDF units on the last page of content

Warning

NOT transform aware.

getLayerPagePositionsback to summary
private List<PagePosition<Layer>> getLayerPagePositions(Layer layer, List<PageBox> pages, RenderingContext ctx)
getLayerPositionsback to summary
public List<PagePosition<Layer>> getLayerPositions(Layer layer)

Returns a list of page positions for a single layer. The page positions are sorted from first page to last and then top to bottom. The page position values are in bottom-up PDF units. Compare to getLayersPositions() which will return page positions for all layers

Warning

NOT transform aware. A transformed layer will return page positions that are not correct.

getLayersPositionsback to summary
public List<PagePosition<Layer>> getLayersPositions()

Returns a list of page positions for all layers in the document. The page positions are sorted from first page to last and then top to bottom. The page position values are in bottom-up PDF units

Warning

NOT transform aware. Transformed layers will return page positions that are not correct.

getListenerback to summary
public PDFCreationListener getListener()
getOutputDeviceback to summary
public PdfBoxOutputDevice getOutputDevice()
getPdfDocumentback to summary
public PDDocument getPdfDocument()

Returns the PDDocument or null if it has been closed.

getPDFVersionback to summary
public float getPDFVersion()
getRootBoxback to summary
public BlockBox getRootBox()
getSharedContextback to summary
public SharedContext getSharedContext()
layoutback to summary
public void layout()
loadDocumentback to summary
private Document loadDocument(String uri)
newLayoutContextback to summary
private LayoutContext newLayoutContext()
newRenderingContextback to summary
private RenderingContext newRenderingContext()
paintPageback to summary
private void paintPage(RenderingContext c, PageBox page)
paintPageFastback to summary
private void paintPageFast(RenderingContext c, PageBox page, DisplayListContainer.DisplayListPageContainer pageOperations, int additionalTranslateX)
requestPageback to summary
public PDPage requestPage(PDDocument doc, float pageWidth, float pageHeight, int pageNumber, int shadowPageNumber)

Implements com.openhtmltopdf.pdfboxout.PageSupplier.requestPage.

Doc from com.openhtmltopdf.pdfboxout.PageSupplier.requestPage.

Called whenever a page or shadow-page is needed.

Parameters
doc:PDDocument

PDDocument the page belongs to

pageWidth:float

Width of page in PDF points (1/72 inch)

pageHeight:float

Height of page in PDF points

pageNumber:int

Number of the layout page - this may differ from the PDF document page if there are previous shadow pages.

shadowPageNumber:int

Number of the shadow-page or -1 if on a main page.

Returns:PDPage

PDPage

Annotations
@Override
setDidValuesback to summary
private void setDidValues(PDDocument doc)
setDocumentFromStringPback to summary
private void setDocumentFromStringP(String content, String baseUrl)
setDocumentPback to summary
private void setDocumentP(String uri)
setDocumentPback to summary
private void setDocumentP(Document doc, String url)
setDocumentPback to summary
private void setDocumentP(File file) throws IOException
setDocumentPback to summary
private void setDocumentP(Document doc, String url, NamespaceHandler nsh)
setListenerback to summary
public void setListener(PDFCreationListener listener)
stringfyMetadataback to summary
private String stringfyMetadata(Element element)
writeNextDocumentback to summary
public void writeNextDocument() throws IOException

Deprecated

Doubt this still works as untested.

Annotations
@Deprecated
writeNextDocumentback to summary
public void writeNextDocument(int initialPageNo) throws IOException

Deprecated

Doubt this still works as untested.

Annotations
@Deprecated
writePDFback to summary
private void writePDF(List<PageBox> pages, RenderingContext c, Rectangle2D firstPageSize, PDDocument doc) throws IOException
writePDFFastback to summary
private void writePDFFast(List<PageBox> pages, RenderingContext c, Rectangle2D firstPageSize, PDDocument doc) throws IOException
com.openhtmltopdf.pdfboxout back to summary

private final Class PdfBoxRenderer.NullUserInterface

extends Object
implements UserInterface
Class Inheritance
All Implemented Interfaces
com.openhtmltopdf.extend.UserInterface

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
isActive(Element
PARAM
e
)

Implements com.openhtmltopdf.extend.UserInterface.isActive.

Gets the active attribute of the UserInterface object

public boolean
isFocus(Element
PARAM
e
)

Implements com.openhtmltopdf.extend.UserInterface.isFocus.

Gets the focus attribute of the UserInterface object

public boolean
isHover(Element
PARAM
e
)

Implements com.openhtmltopdf.extend.UserInterface.isHover.

Gets the hover attribute of the UserInterface object

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NullUserInterfaceback to summary
private NullUserInterface()

Method Detail

isActiveback to summary
public boolean isActive(Element e)

Implements com.openhtmltopdf.extend.UserInterface.isActive.

Doc from com.openhtmltopdf.extend.UserInterface.isActive.

Gets the active attribute of the UserInterface object

Parameters
e:Element

PARAM

Returns:boolean

The active value

isFocusback to summary
public boolean isFocus(Element e)

Implements com.openhtmltopdf.extend.UserInterface.isFocus.

Doc from com.openhtmltopdf.extend.UserInterface.isFocus.

Gets the focus attribute of the UserInterface object

Parameters
e:Element

PARAM

Returns:boolean

The focus value

isHoverback to summary
public boolean isHover(Element e)

Implements com.openhtmltopdf.extend.UserInterface.isHover.

Doc from com.openhtmltopdf.extend.UserInterface.isHover.

Gets the hover attribute of the UserInterface object

Parameters
e:Element

PARAM

Returns:boolean

The hover value