Package com.openhtmltopdf.java2d.api
Class Java2DRendererBuilder
- java.lang.Object
-
- com.openhtmltopdf.outputdevice.helper.BaseRendererBuilder<Java2DRendererBuilder,Java2DRendererBuilderState>
-
- com.openhtmltopdf.java2d.api.Java2DRendererBuilder
-
public class Java2DRendererBuilder extends BaseRendererBuilder<Java2DRendererBuilder,Java2DRendererBuilderState>
Build a Java2D renderer for a given HTML. The renderer allows to get a BufferedImage of the HTML and to render it in components (using Graphics2D).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Java2DRendererBuilder.Graphics2DPaintingReplacedElement
This class is internal to this library, please do not use or override it!-
Nested 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 Constructor Description Java2DRendererBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Java2DRenderer
buildJava2DRenderer()
Java2DRenderer
buildJava2DRenderer(java.io.Closeable diagnosticConsumer)
void
runFirstPage()
useLayoutGraphics
andtoPageProcessor
MUST have been called.void
runPaged()
useLayoutGraphics
andtoPageProcessor
MUST have been called.Java2DRendererBuilder
toPageProcessor(FSPageProcessor pageProcessor)
Output the document in paged format.Java2DRendererBuilder
toSinglePage(FSPageProcessor pageProcessor)
Render everything to a single page.Java2DRendererBuilder
useEnvironmentFonts(boolean useEnvironmentFonts)
Whether to use fonts available in the environment.Java2DRendererBuilder
useLayoutGraphics(java.awt.Graphics2D g2d)
Compulsory method.-
Methods 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
-
-
-
-
Method Detail
-
useLayoutGraphics
public Java2DRendererBuilder useLayoutGraphics(java.awt.Graphics2D g2d)
Compulsory method. The layout graphics are used to measure text and should be from an image or device with the same characteristics as the output graphicsw provided by the page processor.- Parameters:
g2d
-- Returns:
- this for method chaining
-
useEnvironmentFonts
public Java2DRendererBuilder useEnvironmentFonts(boolean useEnvironmentFonts)
Whether to use fonts available in the environment. Enabling environment fonts may mean different text rendering behavior across different environments. The default is not to use environment fonts.
-
toSinglePage
public Java2DRendererBuilder toSinglePage(FSPageProcessor pageProcessor)
Render everything to a single page. I.e. only one big page is genereated, no pagebreak will be done. The page is only as height as needed.
-
toPageProcessor
public Java2DRendererBuilder toPageProcessor(FSPageProcessor pageProcessor)
Output the document in paged format. The user can use the DefaultPageProcessor or use its source as a reference to code their own page processor for advanced usage.- Parameters:
pageProcessor
-- Returns:
- this for method chaining
-
runPaged
public void runPaged() throws java.io.IOException
useLayoutGraphics
andtoPageProcessor
MUST have been called. Also a document MUST have been set with one of the with* methods. This will build the renderer and output each page of the document to the specified page processor.- Throws:
java.lang.Exception
java.io.IOException
-
runFirstPage
public void runFirstPage() throws java.io.IOException
useLayoutGraphics
andtoPageProcessor
MUST have been called. Also a document MUST have been set with one of the with* methods. This will build the renderer and output the first page of the document to the specified page processor.- Throws:
java.lang.Exception
java.io.IOException
-
buildJava2DRenderer
public Java2DRenderer buildJava2DRenderer()
-
buildJava2DRenderer
public Java2DRenderer buildJava2DRenderer(java.io.Closeable diagnosticConsumer)
-
-