Convert HTML into PDF or Image v1.0.0 Help
Converts an HTML code to a PDF or an image file.
How can I use the Step?
You can use Step to convert HTML sources into PDFs for reports, documentation, or invoices and to create images from web pages for thumbnails, previews, or archival purposes.
How does the Step work?
The Step takes an HTML source directly from a URL or as raw HTML code and converts it into a PDF or an image. You can customize file settings, conversion options, and advanced settings.
Prerequisites
- Ensure you have access to the HTML source.
File settings
Provide HTML to convert and specify how to process and store the output file within the platform. Configure the following parameters, including the required ones highlighted in red:
- Source type: Input type for the Source field.
- Source: HTML to convert. URL or raw HTML code based on the selected source type.
- File name: Name of the resulting file. Must not contain slashes
/
or single quotes'
. If a file with the same name and extension already exists in the specified folder, it gets overwritten. - Folder name: Folder withing the Files service where to save the output file. The folder name must not start with a slash
/
, contain consecutive slashes//
or single quote'
characters. To pick the root directory, enter the slash/
character. If the specified folder doesn't exist, it gets created. - File status: File accessibility options. Select
Public
for open access orPrivate
for link-only access. - Set auto-delete time: Option to set a file autodeletion time, ranging from 1 minute to 365 days. The default setting is
30 days
.
Conversion settings
Choose the output file type and configure the corresponding parameters. Use the provided fields and dropdowns to customize each setting to your preference, but enter all the required parameters highlighted in red.
Convert HTML into a PDF file
When converting HTML to PDF, configure these parameters for page content:
- View: Choose between
Predefined
orCustom
display dimensions. - Size: Pick a predefined size or specify a custom width and height depending on your chosen view.
- Orientation: Opt for either
Landscape
orPortrait
. Not available with theCustom
view. - Save background to PDF: Enable this option to include the HTML's background in the PDF.
- Header type: Design and populate the PDF's header as needed.
- Footer type: Specify the footer's design and content.
- Margins: Adjust the spacing around the content. All margins must be numeric values greater than or equal to 0.
Convert HTML into an image
When converting HTML to an image, configure the following parameters:
- Type: Choose the format:
JPEG
orPNG
. - Size: Capture the entire site with
Full
or target a specific section usingClip
. WithClip
, define dimensions and offsets. The width and height values must not exceed 10,000. - Quality: Adjust the image quality by selecting a percentage value between 0 to 100.
- Website resolution: Specify content scaling with standard resolutions or custom dimensions. The width and height values must not exceed 10,000.
- Mobile version of the website: Select to indicate you capture a mobile site.
Advanced settings
Manage how long the Step waits during different stages of webpage loading. These settings are vital for controlling the duration before determining an issue with the conversion process:
- Maximum Navigation Timeout: Determines the time the Step waits for the webpage and its associated resources like images, scripts, and stylesheets to be loaded. Set it between 1-30 seconds, or default to
5 sec
. An error occurs if the webpage doesn't navigate successfully within the set time. - Time to Wait for a Webpage to Load: Determines the time the Step waits for the initial HTML of a webpage to load. This setting doesn't consider additional resources. Set it between 1-20 seconds, or default to
3 sec
. An error occurs if the initial HTML doesn't load within the set time.
Merge field settings
The Step returns the result as a JSON object and stores it under the Merge field name. To learn more about Merge fields and how to work with them, see our Merge fields guide.
Output example
The following table displays output object properties with their descriptions and data types.
Property | Type | Description |
---|---|---|
url | string | The link to the file in the Files service. |
size | number | File size in bytes . |
name | string | The name of the file. |
extension | string | The type and extension of the file in type/extension format. |
ttl | number | The auto-delete date of the file in timestamp format. |
HTML to JPEG conversion output example:
{
"url": "https://files.staging.api.onereach.ai/public/6d35064f-e424-42fe-9e97-145e4e3f72kb/4b91a186-152g-46eb-dr0d-1a8eb355e8d3/image.jpeg",
"size": 50482,
"name": "image.jpeg",
"extension": "image/jpeg",
"ttl": 1681300119268
}
{
"url": "https://files.staging.api.onereach.ai/public/6d35064f-e424-42fe-9e97-145e4e3f72kb/4b91a186-152g-46eb-dr0d-1a8eb355e8d3/image.jpeg",
"size": 50482,
"name": "image.jpeg",
"extension": "image/jpeg",
"ttl": 1681300119268
}
Error Handling
By default, the Step handles errors using a separate exit. So if any error occurs during the Step execution, the Flow proceeds down the error
exit. For more information, see Error and timeout handling.
Reporting
The Step automatically generates Reporting events during its execution, allowing for real-time tracking and analysis of its performance and user interactions. To learn more, see Reporting events
Service dependencies
- studio v3.71.0
- bot deployer v2.22.4
- library v2.18.4
Release notes
v1.0.0
- Initial release