Package com.openhtmltopdf.pdfboxout
Class PdfRendererBuilder
java.lang.Object
com.openhtmltopdf.outputdevice.helper.BaseRendererBuilder<PdfRendererBuilder,PdfRendererBuilderState>
com.openhtmltopdf.pdfboxout.PdfRendererBuilder
public class PdfRendererBuilder
extends BaseRendererBuilder<PdfRendererBuilder,PdfRendererBuilderState>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
List of caches available.static enum
Various level of PDF/A conformance: PDF/A-1, PDF/A-2 and PDF/A-3Nested classes/interfaces inherited from class com.openhtmltopdf.outputdevice.helper.BaseRendererBuilder
BaseRendererBuilder.BaseRendererBuilderState, BaseRendererBuilder.FontStyle, BaseRendererBuilder.FSFontUseCase, BaseRendererBuilder.PageSizeUnits, BaseRendererBuilder.TextDirection
-
Field Summary
Fields inherited from class com.openhtmltopdf.outputdevice.helper.BaseRendererBuilder
PAGE_SIZE_LETTER_HEIGHT, PAGE_SIZE_LETTER_UNITS, PAGE_SIZE_LETTER_WIDTH, state
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBuild a PdfBoxRenderer for further customization.buildPdfRenderer
(Closeable diagnosticConsumer) void
run()
Run the XHTML/XML to PDF conversion and output to an output stream set by toStream.toStream
(OutputStream out) An output stream to output the resulting PDF.useCacheStore
(PdfRendererBuilder.CacheStore which, FSCacheEx<String, FSCacheValue> cache) Use a specific cache.useColorProfile
(byte[] colorProfile) Sets the color profile, needed for PDF/A conformance.useFont
(PDFontSupplier supplier, String fontFamily) Simpler overload foruseFont(PDFontSupplier, String, Integer, FontStyle, boolean)
useFont
(PDFontSupplier supplier, String fontFamily, Integer fontWeight, BaseRendererBuilder.FontStyle fontStyle, boolean subset) LikeBaseRendererBuilder.useFont(FSSupplier, String, Integer, FontStyle, boolean)
but allows to supply a PDFont directly.usePageSupplier
(PageSupplier pageSupplier) Set a PageSupplier that is called whenever a new page is needed.usePDDocument
(org.apache.pdfbox.pdmodel.PDDocument doc) By default, this project creates an entirely in-memoryPDDocument
.usePdfAConformance
(PdfRendererBuilder.PdfAConformance pdfAConformance) Set the PDF/A conformance, typically we use PDF/A-1 Note: PDF/A documents require fonts to be embedded.usePdfUaAccessbility
(boolean pdfUaAccessibility) Whether to conform to PDF/UA or Accessible PDF.usePdfVersion
(float version) Set the PDF version, typically we use 1.7.Deprecated.withProducer
(String producer) Set a producer on the output documentMethods inherited from class com.openhtmltopdf.outputdevice.helper.BaseRendererBuilder
addDOMMutator, applyDiagnosticConsumer, defaultTextDirection, testMode, useDefaultPageSize, useDocumentBuilderFactoryImplementationClass, useExternalResourceAccessControl, useFastMode, useFont, useFont, useFont, useFont, useFont, useFont, useHttpStreamImplementation, useInitialPageNumber, useMathMLDrawer, useObjectDrawerFactory, useProtocolsStreamImplementation, useProtocolsStreamImplementation, useReplacementText, useSVGDrawer, useTransformerFactoryImplementationClass, useUnicodeBidiReorderer, useUnicodeBidiSplitter, useUnicodeCharacterBreaker, useUnicodeLineBreaker, useUnicodeToLowerTransformer, useUnicodeToTitleTransformer, useUnicodeToUpperTransformer, useUriResolver, withDiagnosticConsumer, withFile, withHtmlContent, withUri, withW3cDocument
-
Constructor Details
-
PdfRendererBuilder
public PdfRendererBuilder()
-
-
Method Details
-
run
Run the XHTML/XML to PDF conversion and output to an output stream set by toStream.- Throws:
IOException
-
buildPdfRenderer
Build a PdfBoxRenderer for further customization. Remember to callPdfBoxRenderer.cleanup()
after use.- Returns:
-
buildPdfRenderer
-
toStream
An output stream to output the resulting PDF. The caller is required to close the output stream after calling run.- Parameters:
out
-- Returns:
-
usePdfVersion
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.- Parameters:
version
-- Returns:
-
usePdfAConformance
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.- Parameters:
pdfAConformance
-- Returns:
-
usePdfUaAccessbility
Whether to conform to PDF/UA or Accessible PDF. False by default.- Parameters:
pdfUaAccessibility
-- Returns:
- this for method chaining
-
useColorProfile
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/- Parameters:
colorProfile
-- Returns:
-
usePDDocument
By default, this project creates an entirely in-memoryPDDocument
. The user can use this method to create a document either entirely on-disk or a mix of in-memory and on-disk using thePDDocument
constructor that takes aMemoryUsageSetting
.- Parameters:
doc
- a (usually empty) PDDocument- Returns:
- this for method chaining
-
useFont
public PdfRendererBuilder useFont(PDFontSupplier supplier, String fontFamily, Integer fontWeight, BaseRendererBuilder.FontStyle fontStyle, boolean subset) LikeBaseRendererBuilder.useFont(FSSupplier, String, Integer, FontStyle, boolean)
but allows to supply a PDFont directly. SubclassPDFontSupplier
if you need special font-loading rules (like using a font-cache). -
useFont
Simpler overload foruseFont(PDFontSupplier, String, Integer, FontStyle, boolean)
-
withProducer
Set a producer on the output document- Parameters:
producer
- the name of the producer to set defaults to openhtmltopdf.com- Returns:
- this for method chaining
-
useCacheStore
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:
- this for method chaining.
- See Also:
-
usePageSupplier
Set a PageSupplier that is called whenever a new page is needed.- Parameters:
pageSupplier
-PageSupplier
to use- Returns:
- this for method chaining.
-
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:
- this for method chaining.
-