Top Inners Fields Constructors Methods
com.openhtmltopdf.pdfboxout

public Class PdfRendererBuilder

extends BaseRendererBuilder<PdfRendererBuilder, PdfRendererBuilderState>
Class Inheritance
Imports
com.openhtmltopdf.css.constants.IdentValue, com.openhtmltopdf.extend.*, com.openhtmltopdf.extend.impl.FSNoOpCacheStore, com.openhtmltopdf.outputdevice.helper.AddedFont, .BaseDocument, .BaseRendererBuilder, .PageDimensions, .UnicodeImplementation, com.openhtmltopdf.pdfboxout.PdfBoxFontResolver.FontGroup, com.openhtmltopdf.render.FSFont, com.openhtmltopdf.util.LogMessageId, .XRLog, org.apache.pdfbox.pdmodel.PDDocument, java.awt.FontFormatException, java.io.Closeable, .IOException, .OutputStream, java.util.EnumSet, java.util.logging.Level

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
PdfRendererBuilder.CacheStore

List of caches available.

public static enum
PdfRendererBuilder.PdfAConformance

Various level of PDF/A conformance: PDF/A-1, PDF/A-2 and PDF/A-3

Field Summary

Inherited from com.openhtmltopdf.outputdevice.helper.BaseRendererBuilder:
PAGE_SIZE_LETTER_HEIGHTPAGE_SIZE_LETTER_UNITSPAGE_SIZE_LETTER_WIDTHstate

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public PdfBoxRenderer
buildPdfRenderer()

Build a PdfBoxRenderer for further customization.

public PdfBoxRenderer
buildPdfRenderer(Closeable diagnosticConsumer)

public void
run()

Run the XHTML/XML to PDF conversion and output to an output stream set by toStream.

public PdfRendererBuilder
toStream(OutputStream out)

An output stream to output the resulting PDF.

public PdfRendererBuilder

Returns:

this for method chaining.
useCacheStore
(PdfRendererBuilder.CacheStore which, FSCacheEx<String, FSCacheValue> cache)

Use a specific cache.

public PdfRendererBuilder
useColorProfile(byte[] colorProfile)

Sets the color profile, needed for PDF/A conformance.

public PdfRendererBuilder
useFont(PDFontSupplier supplier, String fontFamily, Integer fontWeight, BaseRendererBuilder.FontStyle fontStyle, boolean subset)

Like BaseRendererBuilder#useFont(FSSupplier, String, Integer, FontStyle, boolean) but allows to supply a PDFont directly.

public PdfRendererBuilder
public PdfRendererBuilder

Returns:

this for method chaining.
usePageSupplier
(PageSupplier pageSupplier)

Set a PageSupplier that is called whenever a new page is needed.

public PdfRendererBuilder

Returns:

this for method chaining
usePDDocument
(PDDocument
a (usually empty) PDDocument
doc
)

By default, this project creates an entirely in-memory PDDocument.

public PdfRendererBuilder
usePdfAConformance(PdfRendererBuilder.PdfAConformance pdfAConformance)

Set the PDF/A conformance, typically we use PDF/A-1 Note: PDF/A documents require fonts to be embedded.

public PdfRendererBuilder

Returns:

this for method chaining
usePdfUaAccessbility
(boolean pdfUaAccessibility)

Whether to conform to PDF/UA or Accessible PDF.

public PdfRendererBuilder
usePdfVersion(float version)

Set the PDF version, typically we use 1.7.

public PdfRendererBuilder

Returns:

this for method chaining.
useSlowMode
()
Deprecated

Fast mode is the default from version 1.0.5.

public PdfRendererBuilder

Returns:

this for method chaining
withProducer
(String
the name of the producer to set defaults to openhtmltopdf.com
producer
)

Set a producer on the output document

Inherited from com.openhtmltopdf.outputdevice.helper.BaseRendererBuilder:
addDOMMutatorapplyDiagnosticConsumerdefaultTextDirectiontestModeuseDefaultPageSizeuseDocumentBuilderFactoryImplementationClassuseExternalResourceAccessControluseFastModeuseFontuseFontuseFontuseFontuseFontuseFontuseHttpStreamImplementationuseInitialPageNumberuseMathMLDraweruseObjectDrawerFactoryuseProtocolsStreamImplementationuseProtocolsStreamImplementationuseReplacementTextuseSVGDraweruseTransformerFactoryImplementationClassuseUnicodeBidiReordereruseUnicodeBidiSplitteruseUnicodeCharacterBreakeruseUnicodeLineBreakeruseUnicodeToLowerTransformeruseUnicodeToTitleTransformeruseUnicodeToUpperTransformeruseUriResolverwithDiagnosticConsumerwithFilewithHtmlContentwithUriwithW3cDocument

Constructor Detail

PdfRendererBuilderback to summary
public PdfRendererBuilder()

Method Detail

buildPdfRendererback to summary
public PdfBoxRenderer buildPdfRenderer()

Build a PdfBoxRenderer for further customization. Remember to call PdfBoxRenderer#cleanup() after use.

buildPdfRendererback to summary
public PdfBoxRenderer buildPdfRenderer(Closeable diagnosticConsumer)
runback to summary
public void run() throws IOException

Run the XHTML/XML to PDF conversion and output to an output stream set by toStream.

toStreamback to summary
public PdfRendererBuilder toStream(OutputStream out)

An output stream to output the resulting PDF. The caller is required to close the output stream after calling run.

useCacheStoreback to summary
public PdfRendererBuilder useCacheStore(PdfRendererBuilder.CacheStore which, FSCacheEx<String, FSCacheValue> cache)

Use a specific cache. Cache values should be thread safe, so provided your cache store itself is thread safe can be used accross threads.

Returns:PdfRendererBuilder

this for method chaining.

See Also
CacheStore
useColorProfileback to summary
public PdfRendererBuilder useColorProfile(byte[] colorProfile)

Sets the color profile, needed for PDF/A conformance. You can use the sRGB.icc from https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/resources/org/apache/pdfbox/resources/pdfa/

useFontback to summary
public PdfRendererBuilder useFont(PDFontSupplier supplier, String fontFamily, Integer fontWeight, BaseRendererBuilder.FontStyle fontStyle, boolean subset)

Like BaseRendererBuilder#useFont(FSSupplier, String, Integer, FontStyle, boolean) but allows to supply a PDFont directly. Subclass PDFontSupplier if you need special font-loading rules (like using a font-cache).

useFontback to summary
public PdfRendererBuilder useFont(PDFontSupplier supplier, String fontFamily)

Simpler overload for useFont(PDFontSupplier, String, Integer, FontStyle, boolean)

usePageSupplierback to summary
public PdfRendererBuilder usePageSupplier(PageSupplier pageSupplier)

Set a PageSupplier that is called whenever a new page is needed.

Parameters
pageSupplier:PageSupplier

PageSupplier to use

Returns:PdfRendererBuilder

this for method chaining.

usePDDocumentback to summary
public PdfRendererBuilder usePDDocument(PDDocument doc)

By default, this project creates an entirely in-memory PDDocument. The user can use this method to create a document either entirely on-disk or a mix of in-memory and on-disk using the PDDocument constructor that takes a MemoryUsageSetting.

Parameters
doc:PDDocument

a (usually empty) PDDocument

Returns:PdfRendererBuilder

this for method chaining

usePdfAConformanceback to summary
public PdfRendererBuilder usePdfAConformance(PdfRendererBuilder.PdfAConformance pdfAConformance)

Set the PDF/A conformance, typically we use PDF/A-1 Note: PDF/A documents require fonts to be embedded. So if this is not set to NONE, the built-in fonts will not be available and currently any text without a specified and embedded font will cause the renderer to crash with an exception.

usePdfUaAccessbilityback to summary
public PdfRendererBuilder usePdfUaAccessbility(boolean pdfUaAccessibility)

Whether to conform to PDF/UA or Accessible PDF. False by default.

Returns:PdfRendererBuilder

this for method chaining

usePdfVersionback to summary
public PdfRendererBuilder usePdfVersion(float version)

Set the PDF version, typically we use 1.7. If you set a lower version, it is your responsibility to make sure no more recent PDF features are used.

useSlowModeback to summary
public PdfRendererBuilder useSlowMode()

Deprecated

Fast mode is the default from version 1.0.5. You can call this temporary method to use the slow renderer until it is removed in a near future version. This method is marked deprecated to prompt you to upgrade to the fast renderer.

Returns:PdfRendererBuilder

this for method chaining.

Annotations
@Deprecated
withProducerback to summary
public PdfRendererBuilder withProducer(String producer)

Set a producer on the output document

Parameters
producer:String

the name of the producer to set defaults to openhtmltopdf.com

Returns:PdfRendererBuilder

this for method chaining

com.openhtmltopdf.pdfboxout back to summary

public final Enum PdfRendererBuilder.CacheStore

extends Enum<PdfRendererBuilder.CacheStore>
Class Inheritance

List of caches available.

Field Summary

Modifier and TypeField and Description
public static final PdfRendererBuilder.CacheStore
PDF_FONT_METRICS

Caches font metrics, based on a combined key of family name, weight and style.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static PdfRendererBuilder.CacheStore
public static PdfRendererBuilder.CacheStore[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

PDF_FONT_METRICSback to summary
public static final PdfRendererBuilder.CacheStore PDF_FONT_METRICS

Caches font metrics, based on a combined key of family name, weight and style. Using this cache avoids loading fallback fonts if the metrics are already in the cache and the previous fonts contain the needed characters.

Constructor Detail

CacheStoreback to summary
private CacheStore()

Method Detail

valueOfback to summary
public static PdfRendererBuilder.CacheStore valueOf(String name)
valuesback to summary
public static PdfRendererBuilder.CacheStore[] values()
com.openhtmltopdf.pdfboxout back to summary

public final Enum PdfRendererBuilder.PdfAConformance

extends Enum<PdfRendererBuilder.PdfAConformance>
Class Inheritance

Various level of PDF/A conformance: PDF/A-1, PDF/A-2 and PDF/A-3

Field Summary

Modifier and TypeField and Description
public static final PdfRendererBuilder.PdfAConformance
private final int
public static final PdfRendererBuilder.PdfAConformance
public static final PdfRendererBuilder.PdfAConformance
public static final PdfRendererBuilder.PdfAConformance
public static final PdfRendererBuilder.PdfAConformance
public static final PdfRendererBuilder.PdfAConformance
public static final PdfRendererBuilder.PdfAConformance
public static final PdfRendererBuilder.PdfAConformance
public static final PdfRendererBuilder.PdfAConformance
private final float
private final String

Constructor Summary

AccessConstructor and Description
private
PdfAConformance(int part, String value, float pdfVersion)

Method Summary

Modifier and TypeMethod and Description
public String
public int
public float
public static PdfRendererBuilder.PdfAConformance
public static PdfRendererBuilder.PdfAConformance[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

NONEback to summary
public static final PdfRendererBuilder.PdfAConformance NONE
partback to summary
private final int part
PDFA_1_Aback to summary
public static final PdfRendererBuilder.PdfAConformance PDFA_1_A
PDFA_1_Bback to summary
public static final PdfRendererBuilder.PdfAConformance PDFA_1_B
PDFA_2_Aback to summary
public static final PdfRendererBuilder.PdfAConformance PDFA_2_A
PDFA_2_Bback to summary
public static final PdfRendererBuilder.PdfAConformance PDFA_2_B
PDFA_2_Uback to summary
public static final PdfRendererBuilder.PdfAConformance PDFA_2_U
PDFA_3_Aback to summary
public static final PdfRendererBuilder.PdfAConformance PDFA_3_A
PDFA_3_Bback to summary
public static final PdfRendererBuilder.PdfAConformance PDFA_3_B
PDFA_3_Uback to summary
public static final PdfRendererBuilder.PdfAConformance PDFA_3_U
pdfVersionback to summary
private final float pdfVersion
valueback to summary
private final String value

Constructor Detail

PdfAConformanceback to summary
private PdfAConformance(int part, String value, float pdfVersion)

Method Detail

getConformanceValueback to summary
public String getConformanceValue()
getPartback to summary
public int getPart()
getPdfVersionback to summary
public float getPdfVersion()
valueOfback to summary
public static PdfRendererBuilder.PdfAConformance valueOf(String name)
valuesback to summary
public static PdfRendererBuilder.PdfAConformance[] values()