Convert
The Convert APIs are used to convert content (HTML, URLs or Office Documents) to PDF. On this page, we'll dive into the different convert endpoints you can use to carry out conversions.
Convert a URL to PDF
This endpoint allows you to convert a URL to PDF
Required attributes
- Name
url
- Type
- string
- Description
The URL to convert into a PDF
Optional attributes
- Name
engine_options
- Type
- object
- Description
PDF Engine options
- Name
timeout
- Type
- integerDefault: 30000
- Description
Timeout in milliseconds.
- Name
waitForNetworkToIdle
- Type
- booleanDefault: false
- Description
If enabled, the engine will wait for the network activity to stop before taking action. If you get partial renderings, setting this to true might help.
- Name
options
- Type
- object
- Description
PDF Page options
- Name
format
- Type
- stringDefault: A4
- Description
PDF Page format. Allowed: ['Letter', 'Legal', 'Tabloid', 'Ledger', 'A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6']
- Name
landscape
- Type
- booleanDefault: false
- Description
Render in landscape layout. Default is portrait mode.
- Name
margin
- Type
- object
- Description
Page Margin
- Name
top
- Type
- integer
- Description
- Name
right
- Type
- integer
- Description
- Name
bottom
- Type
- integer
- Description
- Name
left
- Type
- integer
- Description
- Name
printBackground
- Type
- booleanDefault: false
- Description
Print background graphics.
- Name
omitBackground
- Type
- booleanDefault: false
- Description
Hides default white background and allows generating pdfs with transparency.
- Name
scale
- Type
- numberDefault: 1
- Description
Scales the rendering of the web page. Amount must be between 0.1 and 2.
- Name
displayHeaderFooter
- Type
- booleanDefault: false
- Description
Whether to show the header and footer.
- Name
headerTemplate
- Type
- string
- Description
HTML template for the print header. Should be valid HTML with the following classes used to inject values into them:
date
formatted print datetitle
document titleurl
document locationpageNumber
current page numbertotalPages
total pages in the document
- Name
footerTemplate
- Type
- string
- Description
HTML template for the print footer. Has the same constraints and support for special classes as headerTemplate.
- Name
pageRanges
- Type
- string
- Description
Paper ranges to print, e.g. 1-5, 8, 11-13.
Request
curl -X POST https://api.pdfloom.com/v1/convert/url \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"options": {
"format": "A4",
"margin": {
"top": 10,
"left": 10
}
}
}'
Response
{
"success": true,
"response": "https://pdfloom-processed.s3.amazonaws.com/users/1/pdf/0190fd32-cee4-4d60-b94a-0c313c695b0a.pdf?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVXUMWHOQWRBIZZCO%2F20240815%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240815T070406Z&X-Amz-SignedHeaders=host&X-Amz-Expires=1800&X-Amz-Signature=1ef4e4d3cf775b75bb117d49d08dee2f973c5b692aaea35b574bff7512b0f088",
"fileSize": 6139
}
Convert HTML to PDF
This endpoint allows you to send a new message to one of your conversations.
Required attributes
- Name
content
- Type
- string
- Description
The HTML content that will be rendered by the engine before converting to PDF
Optional attributes
- Name
engine_options
- Type
- object
- Description
PDF Page options
- Name
timeout
- Type
- integerDefault: 30000
- Description
Timeout in milliseconds.
- Name
waitForNetworkToIdle
- Type
- booleanDefault: false
- Description
If enabled, the engine will wait for the network activity to stop before taking action. If you get partial renderings, setting this to true might help.
- Name
options
- Type
- object
- Description
PDF Page options
- Name
format
- Type
- string
- Description
PDF Page format. Allowed: ['Letter', 'Legal', 'Tabloid', 'Ledger', 'A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6']
- Name
landscape
- Type
- booleanDefault: false
- Description
Render in landscape layout. Default is portrait mode.
- Name
margin
- Type
- object
- Description
Page Margin
- Name
top
- Type
- integer
- Description
- Name
right
- Type
- integer
- Description
- Name
bottom
- Type
- integer
- Description
- Name
left
- Type
- integer
- Description
- Name
printBackground
- Type
- booleanDefault: false
- Description
Print background graphics.
- Name
omitBackground
- Type
- booleanDefault: false
- Description
Hides default white background and allows generating pdfs with transparency.
- Name
scale
- Type
- numberDefault: 1
- Description
Scales the rendering of the web page. Amount must be between 0.1 and 2.
- Name
displayHeaderFooter
- Type
- booleanDefault: false
- Description
Whether to show the header and footer.
- Name
headerTemplate
- Type
- string
- Description
HTML template for the print header. Should be valid HTML with the following classes used to inject values into them:
date
formatted print datetitle
document titleurl
document locationpageNumber
current page numbertotalPages
total pages in the document
- Name
footerTemplate
- Type
- string
- Description
HTML template for the print footer. Has the same constraints and support for special classes as headerTemplate.
- Name
pageRanges
- Type
- string
- Description
Paper ranges to print, e.g. 1-5, 8, 11-13.
Request
curl -X POST https://api.pdfloom.com/v1/convert/url \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"content": "<html><head></head><body><h2>Hello, World!</h2></body></html>",
"options": {
"format": "A4",
"margin": {
"top": 10,
"left": 10
}
}
}'
Response
{
"success": true,
"response": "https://pdfloom-processed.s3.amazonaws.com/users/1/pdf/0190fd32-cee4-4d60-b94a-0c313c695b0a.pdf?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVXUMWHOQWRBIZZCO%2F20240815%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240815T070406Z&X-Amz-SignedHeaders=host&X-Amz-Expires=1800&X-Amz-Signature=1ef4e4d3cf775b75bb117d49d08dee2f973c5b692aaea35b574bff7512b0f088",
"fileSize": 6139
}
Convert Documents to PDF
This endpoint allows you to convert an office document (excel, word, etc.) to PDF
Required attributes
- Name
file
- Type
- file
- Description
The document file to convert to PDF. Allowed types: ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']
Request
curl --location 'https://api.pdfloom.com/v1/convert/docs' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--form 'file=@"/path/to/file/test.docx"'
Response
{
"success": true,
"response": "https://pdfloom-processed.s3.amazonaws.com/users/1/pdf/0190fd32-cee4-4d60-b94a-0c313c695b0a.pdf?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVXUMWHOQWRBIZZCO%2F20240815%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240815T070406Z&X-Amz-SignedHeaders=host&X-Amz-Expires=1800&X-Amz-Signature=1ef4e4d3cf775b75bb117d49d08dee2f973c5b692aaea35b574bff7512b0f088",
"fileSize": 6139
}