HtmlToPdfPostExecutorV2

Prev Next

Class name

com.ebd.hub.datawizard.postexec.HtmlToPdfPostExecutorV2

Description

This post-executor converts HTML files to PDF files. It is configured via a properties file.

Two conversion engines are supported: Aspose (default) and Flying Saucer. The engine is controlled via the engine property.

Configure profile

Use a profile without mapping. Use a "File" input agent to read the HTML file in Phase 1, and configure a "File" response path with this post-executor in Phase 6. For the response path content, select "as received".

Engine comparison

Criterion

Aspose (default)

Flying Saucer

CSS support

Comprehensive, including many aspects of CSS3.

Only CSS 2.1

JavaScript / <script> tags

Not supported

Not supported.

HTML source

Any HTML, including from external or poorly controlled sources.

Static, self-generated HTML with CSS 2.1-compliant styling.

Custom CSS (custom.css)

Not available

Available—applies the original styling.

License

Commercial

Open Source

Property activation

engine=aspose or omit the property

engine=flying-saucer

Aspose is recommended when the HTML originates from external or hard-to-control sources, uses modern CSS, or when the effort required to achieve CSS 2.1 compliance is not justified.

Flying Saucer is recommended when the HTML is specifically generated for this conversion, is fully under your control, and can be designed to be CSS 2.1-compliant. This is especially true when custom.css is required to produce an exact, reproducible output.

Flying Saucer (starting with Release 26.2)

This is enabled via engine=flying-saucer. It refers to the open-source project Flying Saucer.

NOTE An invalid value for engine (i.e., neither aspose nor flying-saucer) will result in an exception. The library applies all CSS styling from the original HTML code, unless it can't process it.

Requirements and restrictions

  • The HTML input document must consist entirely of static HTML. <script> tags are not executed and are ignored.

  • Only CSS 2.1 is supported. CSS3 features (e.g., Flexbox, Grid, many modern selectors) are not supported or are only partially supported.

  • The HTML document must therefore include all necessary styles inline or via a <style> block that are compatible with CSS 2.1.

Properties

Property

Type

Requirement

Engine

Description

engine

String

No

Both

Conversion engine. Valid values: aspose, flying-saucer. Default: aspose (even if the property is missing). Invalid values result in an exception.

format

String

Yes

Both

Size. Examples: A4, A3, LETTER.

orientation

String

Yes

Both

Page orientation. Valid values: PORTRAIT, LANDSCAPE.

margin.top

Float

No

Both

Top margin in mm. Default: 0.

margin.bottom

Float

No

Both

Bottom margin in mm. Default: 0.

margin.left

Float

No

Both

Left margin in mm. Default: 0.

margin.right

Float

No

Both

Right margin in mm. Default: 0.

font.size

Float

No

Aspose

Font size in points. Example: 12.0.

font.linespacing

Float

No

Aspose

Line spacing as a factor. Example: 1.0 = single line spacing.

font.style

Integer

No

Aspose

Font style. 0 = normal, 1 = bold, 2 = italic, 3 = bold + italic.

custom.css

String

No

Flying Saucer

Path to a CSS file containing additional styles. This is applied after the original HTML styling and overrides it in case of conflicts. Must be CSS 2.1-compliant.

IMPORTANT

The contents of the custom.css file are not checked or supported by Lobster. Make sure the file is CSS 2.1-compliant. Otherwise, unexpected display issues may occur.

Examples

Example 1: Aspose (default)

format=A4
orientation=LANDSCAPE
margin.top=3
margin.bottom=3
margin.left=3
margin.right=0
font.linespacing=1.0
font.size=12.0
font.style=1

Example 2: Flying Saucer with custom CSS

engine=flying-saucer
format=A4
orientation=PORTRAIT
margin.top=10
margin.bottom=10
margin.left=15
margin.right=15
custom.css=/path/to/custom-overrides.css