When generating PDFs, use the pdf_options parameter to control page size, margins, scaling, and background printing.
You can use either of these flows:
Create an image, then render it as a PDF: Create the image normally, then add .pdf to the returned image URL.
Render it as a PDF directly: Include format: "pdf" when creating the image. The URL in the creation response will already end in .pdf.
In both cases, the PDF is rendered and saved separately when its URL is requested. The format parameter only controls the URL returned by the creation request; it does not change the stored image definition.
Parameters
The pdf_options object accepts the following properties:
Property
Type
Description
page_width
String
Width of the page with unit (px, in, cm, mm, pt). Example: 8.5in
page_height
String
Height of the page with unit (px, in, cm, mm, pt). Example: 11in
scale
Number
Scale of the webpage rendering. Range: 0.1 to 2. Default: 1
Whether to print background graphics. Default: false
Common page sizes
Size
Dimensions
Use Case
Letter
8.5in x 11in
US standard documents
A4
210mm x 297mm
International standard
Legal
8.5in x 14in
Legal documents
A5
148mm x 210mm
Smaller documents
Example usage
Create an image, then render it as a PDF
Create an image and access it as PDF:
curl -X POST https://hcti.io/v1/image -u'UserID:APIKey'\-H"Content-Type: application/json"\-d'{
"html": "<h1>Invoice #1234</h1><p>Thank you for your purchase.</p>"
}'
Then append .pdf to the returned URL:
https://hcti.io/v1/image/abc123.pdf
Return a PDF URL directly
Set format to pdf when creating the image:
curl -X POST https://hcti.io/v1/image -u'UserID:APIKey'\-H"Content-Type: application/json"\-d'{
"html": "<h1>Invoice #1234</h1><p>Thank you for your purchase.</p>",
"format": "pdf",
"pdf_options": {
"print_background": true
}
}'
The response URL already includes the PDF extension: