API V2

Convert Html to PDF

Connector ID: Html To Pdf

The files with an extension “.html” if having content, can be made into PDF files, using this PDF4me connector in a simple single step of conversion. This can be used to combine with many web pages and create an integrated process.

  • Method: POST
  • Endpoint: /api/v2/ConvertHtmlToPdf

Parameters

File Contentbase64, Required

Map the file content from the previous action. Supports single HTML or HTML files in ZIP

HTML File NameString, Required

The source HTML file name with .html extension

index File PathString, Required

Index file path required when the input file is ZIP

LayoutString, Required

The layout of the output PDF file. The options are

  • Portrait
  • Landscape
FormatString, Required
Default: A4

You can select any format -

  • A0, A1, A2, A3, A4, A5, A6, A7, A8
  • Tabloid
  • Legal
  • Statement
  • Executive
Scaledecimal, Required

Specify the scale as a decimal value between 0 and 0.8. The scale determines how much the content is resized. A smaller value reduces the size, while a larger value increases it within the allowed range. For example, entering 0.8 will scale the content to 80% of its original size.

TopMarginString, Required

Specify the value for TopMargin based on your requirement. This defines the space between the top edge of the page (or container) and the content. The value must be provided with a valid unit (e.g., pixels). For example, entering 40px will set a top margin of 40 pixels.

BottomMarginString, Required

Specify the value for BottomMargin according to your requirement. This setting controls the space between the bottom edge of the page (or container) and the content. The value must be entered with a valid unit (e.g., pixels).
For example, entering 40px will create a bottom margin of 40 pixels, ensuring that the content is shifted upward from the bottom edge.

LeftMarginString, Required

Specify the value for LeftMargin according to your requirement. This defines the space between the left edge of the page (or container) and the content. The value must include a valid unit (e.g., pixels).
For example, entering 40px will create a left margin of 40 pixels, shifting the content inward from the left edge.

RightMarginString, Required

Specify the value for RightMargin according to your requirement. This defines the space between the right edge of the page (or container) and the content. The value must be provided with a valid unit (e.g., pixels).
For example, entering 40px will create a right margin of 40 pixels, shifting the content inward from the right edge.

PrintBackgroundboolean, Required
Default: true
  • Selecting true will print the background (such as colors, patterns, or images) along with the content in the PDF.
  • Selecting false will exclude the background, and only the main content will be displayed in the PDF.
DisplayHeaderFooterboolean, Required
Default: true
  • Selecting true will include the header and footer (such as page numbers, titles, or other set information) in the PDF
  • Selecting false will exclude the header and footer, so only the main content will be shown.

Output

File ContentBinary

Output file content from PDF4me action

File NameString

Output file name from PDF4me action

Header
Content-Type: application/json
Authorization: Please copy key from the link.

Payload

{
  "docContent": "Please put HTML base64 content",
  "docName": "output.pdf",
  "indexFilePath": "please input file path",
  "layout": "Portrait",
  "format": "A4",
  "scale": 0.8,
  "topMargin": "40px",
  "bottomMargin": "40px",
  "leftMargin": "40px",
  "rightMargin": "40px",
  "printBackground": true,
  "displayHeaderFooter": true
}

PDF4me api samples

CSharp(C#)
Java
JavaScript
Python
Salesforce
n8n
Google Script
AWS Lambda