HTML to PDF Converter

Overview

This Snap reads one or more binary HTML streams and writes them to as many PDF binary output streams. It also allows you to configure the page size and fonts for rendering the output PDF files.



Prerequisites

None.

Limitations

  • Some modern CSS features such as flexbox or grid layout, may not be rendered with complete accuracy in the output PDF data.
  • By default, character support is largely limited to western European characters, Arabic numerals, and basic symbols. Characters that cannot be rendered with the available fonts will be rendered as #. For expanded character support, such as unicode characters, additional languages, or symbols like Emoji, provide the font that supports these characters. Learn more on the Best practices to render custom fonts.

Snap views

View Description Examples of upstream and downstream Snaps
Input This Snap has exactly one binary input view. The input should contain the binary data of an HTML file.
Output This Snap has exactly one binary output view. The output contains the binary data of a PDF file.
Error Learn more about Error handling in Pipelines.

Examples

Snap settings

Note: Learn more about the common controls in the Snap settings dialog
Field set/Field name Description
Label

String

Required. Specify a unique name for the Snap. Modify this to be more appropriate, especially if there are more than one of the same Snap in the pipeline.

Default value: HTML to PDF Converter

Example: Convert HTML to PDF with fonts

HTML file location

String/Expression

Specify the URL of the source HTML file to render as-is the images and other references in the CSS from the HTML source in the PDF output. The Snap uses the base URL in this address to resolve the image paths and CSS references. This field supports URIs that use HTTP, HTTPS, and file (file://) protocols for the source HTML file definition.
Important: This field does not support sldb:// location for the source HTML location.

Default value: N/A

Example: https://html.spec.whatwg.org/multipage/workers.html

Page dimensions

Use this field set to define the page dimensions for the PDF output.

Measurement unit

Dropdown list

Specify the unit of measurement for the page dimensions.

  • Inches (in)
  • Millimeters (mm)

Default value: Inches (in)

Example: Millimeters (mm)

Width

Decimal

Specify the width for each page in the PDF output.

Default value: N/A

Example: 8.5

Height

Decimal

Specify the height for each page in the PDF output.

Default value: N/A

Example: 11.67

Applied fonts

Provide the list of fonts used in the styling of the HTML content that should be applied to text in the created PDF file and the respective .ttf file locations.

Note: The Snap supports only TrueType fonts (TTF) for the PDF conversion.
Font family name

String

Specify the name of the font family. Make sure that it exactly matches the font-family used in the HTML file's CSS definition.

Default value: N/A

Example: Alata
Font file location

String/Expression

Specify the location of the TrueType font (.ttf) file. You can upload and specify the corresponding .ttf file from the SLDB or the local file system (file://).

Default value: N/A

Example: alata-regular.ttf
Error on font failure

Checkbox

Select this checkbox to enable the Snap to report an error instead of falling back to available font backups when a specified font file cannot be accessed or applied.

Default status: Deselected

Snap execution

Dropdown list

Choose one of the three modes in which the Snap executes. Available options are:
  • Validate & Execute: Performs limited execution of the Snap and generates a data preview during pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.
  • Execute only: Performs full execution of the Snap during pipeline execution without generating preview data.
  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Default value: Validate & Execute

Example: Execute only

Best practices to render custom fonts

The following are best practices for providing custom fonts:
  • The font name provided in the Snap's Applied fonts > Font family name should match a defined font-family name in the CSS of the HTML content.
  • @font-face rules in the CSS may result in adverse behavior in the rendered PDF due to conflicts in font source when font files are provided through Snap settings. For best results, avoid using @font-face rules in the HTML's CSS.

Troubleshooting

Error/Warning Reason Resolution
Warning: Incorrect File Path: <file/path/with/file.name> The asset used/referenced in the HTML file (source) could not be found. Specify the HTML file location for the HTML to PDF Converter Snap to resolve these asset paths.
Warning: The file path: /style/css/manual.css is not in the current org The Snap cannot locate/access the CSS file specified/referenced in the HTML source.
Warning: The file path: /style/css/fonts/mynewfont.ttf is not in the current org The Snap cannot locate/access the font (.ttf) file specified/referenced in the HTML source.