Class name |
|
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 / | 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 ( | Not available | Available—applies the original styling. |
License | Commercial | Open Source |
Property activation |
|
|
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 |
|---|---|---|---|---|
| String | No | Both | Conversion engine. Valid values: |
| String | Yes | Both | Size. Examples: |
| String | Yes | Both | Page orientation. Valid values: |
| Float | No | Both | Top margin in mm. Default: |
| Float | No | Both | Bottom margin in mm. Default: |
| Float | No | Both | Left margin in mm. Default: |
| Float | No | Both | Right margin in mm. Default: |
| Float | No | Aspose | Font size in points. Example: |
| Float | No | Aspose | Line spacing as a factor. Example: |
| Integer | No | Aspose | Font style. |
| 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.cssfile 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=1Example 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