Package com.openhtmltopdf.pdfboxout
Class PdfBoxRenderer
- java.lang.Object
-
- com.openhtmltopdf.pdfboxout.PdfBoxRenderer
-
- All Implemented Interfaces:
PageSupplier
,Closeable
,AutoCloseable
public class PdfBoxRenderer extends Object implements Closeable, PageSupplier
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
cleanup()
Deprecated.Use close instead.void
close()
Cleanup thread resources.void
createPDF()
Creates a PDF with setup specified by builder.void
createPDF(OutputStream os)
Deprecated.Use builder to set output stream.void
createPDF(OutputStream os, boolean finish)
Deprecated.Use builder to set output stream.void
createPDF(OutputStream os, boolean finish, int initialPageNo)
Deprecated.Use builder to set output stream.void
createPDFWithoutClosing()
Creates a PDF with setup specified by builder.void
exportText(Writer writer)
Deprecated.unused and untested.List<PagePosition<Box>>
findPagePositionsByID(Pattern pattern)
void
finishPDF()
Deprecated.Document
getDocument()
float
getDotsPerPoint()
PdfBoxFontResolver
getFontResolver()
Get the PDF-BOX font resolver.float
getLastContentBottom()
Returns the bottom Y postion in bottom-up PDF units on the last page of content.List<PagePosition<Layer>>
getLayerPositions(Layer layer)
Returns a list of page positions for a single layer.List<PagePosition<Layer>>
getLayersPositions()
Returns a list of page positions for all layers in the document.PDFCreationListener
getListener()
PdfBoxOutputDevice
getOutputDevice()
org.apache.pdfbox.pdmodel.PDDocument
getPdfDocument()
Returns the PDDocument or null if it has been closed.float
getPDFVersion()
BlockBox
getRootBox()
SharedContext
getSharedContext()
void
layout()
org.apache.pdfbox.pdmodel.PDPage
requestPage(org.apache.pdfbox.pdmodel.PDDocument doc, float pageWidth, float pageHeight, int pageNumber, int shadowPageNumber)
Called whenever a page or shadow-page is needed.void
setListener(PDFCreationListener listener)
void
writeNextDocument()
Deprecated.Doubt this still works as untested.void
writeNextDocument(int initialPageNo)
Deprecated.Doubt this still works as untested.
-
-
-
Method Detail
-
getDocument
public Document getDocument()
-
getPdfDocument
public org.apache.pdfbox.pdmodel.PDDocument getPdfDocument()
Returns the PDDocument or null if it has been closed.
-
getFontResolver
public PdfBoxFontResolver getFontResolver()
Get the PDF-BOX font resolver. Can be used to add fonts in code.- Returns:
-
getPDFVersion
public float getPDFVersion()
-
layout
public void layout()
-
createPDF
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.- Throws:
IOException
-
createPDFWithoutClosing
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().- Throws:
IOException
-
createPDF
@Deprecated public void createPDF(OutputStream os) throws IOException
Deprecated.Use builder to set output stream.- Parameters:
os
-- Throws:
IOException
-
writeNextDocument
@Deprecated public void writeNextDocument() throws IOException
Deprecated.Doubt this still works as untested.- Throws:
IOException
-
writeNextDocument
@Deprecated public void writeNextDocument(int initialPageNo) throws IOException
Deprecated.Doubt this still works as untested.- Throws:
IOException
-
finishPDF
@Deprecated public void finishPDF() throws IOException
Deprecated.- Throws:
IOException
-
createPDF
@Deprecated public void createPDF(OutputStream os, boolean finish) throws IOException
Deprecated.Use builder to set output stream.- Throws:
IOException
-
createPDF
@Deprecated 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.- Throws:
IOException
-
getOutputDevice
public PdfBoxOutputDevice getOutputDevice()
-
getSharedContext
public SharedContext getSharedContext()
-
exportText
@Deprecated public void exportText(Writer writer) throws IOException
Deprecated.unused and untested.- Parameters:
writer
-- Throws:
IOException
-
getRootBox
public BlockBox getRootBox()
-
getDotsPerPoint
public float getDotsPerPoint()
-
findPagePositionsByID
public List<PagePosition<Box>> findPagePositionsByID(Pattern pattern)
-
getListener
public PDFCreationListener getListener()
-
setListener
public void setListener(PDFCreationListener listener)
-
cleanup
@Deprecated public void cleanup()
Deprecated.Use close instead.
-
close
public void close()
Cleanup thread resources. MUST be called after finishing with the renderer.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
requestPage
public org.apache.pdfbox.pdmodel.PDPage requestPage(org.apache.pdfbox.pdmodel.PDDocument doc, float pageWidth, float pageHeight, int pageNumber, int shadowPageNumber)
Description copied from interface:PageSupplier
Called whenever a page or shadow-page is needed.- Specified by:
requestPage
in interfacePageSupplier
- Parameters:
doc
-PDDocument
the page belongs topageWidth
- Width of page in PDF points (1/72 inch)pageHeight
- Height of page in PDF pointspageNumber
- Number of the layout page - this may differ from the PDF document page if there are previous shadow pages.shadowPageNumber
- Number of the shadow-page or -1 if on a main page.- Returns:
PDPage
-
getLastContentBottom
public float getLastContentBottom()
Returns the bottom Y postion in bottom-up PDF units on the last page of content. WARNING: NOT transform aware.
-
getLayersPositions
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.
-
getLayerPositions
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 togetLayersPositions()
which will return page positions for all layers. WARNING: NOT transform aware. A transformed layer will return page positions that are not correct.
-
-