doc. render_ pdf
Turn HTML into a PDF, such as an invoice, report, or receipt.
25 credits. Per document.
Example prompt
Send this to your AI app when Heelo is connected:
Generate a PDF receipt for this invoice
Input fields
| Field | Type | Description |
|---|---|---|
htmlRequired | string | The HTML document to render. |
engine | "auto" | "weasyprint" | "chromium" | auto uses WeasyPrint unless the HTML needs JavaScript. weasyprint: own templates, no JS. chromium: scripted charts, third-party HTML, WYSIWYG. |
page | object | Page geometry, e.g. {"size":"A4","margin":"20mm"}. Also orientation, and header / footer as a string or {left,center,right}; {page} and {pages} become page numbers. |
media | "print" | "screen" | CSS media to render with. screen gives the on-screen look. |
allow_remote_resources | boolean | Let the document load http(s) images/styles from public hosts. |
wait_ms | integer | Chromium only: extra settle time after load, max 15000. |
return_data | boolean | Also return the PDF as base64 in `data`. |
end_user_id | string | Which of your end users the render is stored for; doc.extract_* must pass the same one to read it. |
Output fields
The fields in data when status is success.
| Field | Type | Description |
|---|---|---|
asset_id | string | Readable by doc.extract_* as source.asset_id for 30 days. Null when not stored. |
bytes | integer | Size of the rendered document. |
pages | integer | Page count for a PDF. Null for DOCX/XLSX, which have no layout. |
content_type | string | |
filename | string | |
engine_used | string | |
engine_reason | string | Why that engine was chosen (PDF only). |
render_ms | integer | |
stored | boolean | False when the document could not be stored for this caller; see `data`. |
data | string | The document as base64, when not stored or when asked for. |
warnings | array of string | |
limitations | array of string |
Code
The call with the input fields that the tool needs. Replace each word in capitals, such as HTML. Set HEELO_API_KEY to your API key.
import os
import requests
response = requests.post(
"https://toolsprimitives.uk/v1/tools/doc.render_pdf/invoke",
headers={"Authorization": f"Bearer {os.environ['HEELO_API_KEY']}"},
json={"input": {
"html": "HTML",
}},
timeout=120,
)
response.raise_for_status()
print(response.json())// Node.js 18 or newer, in an ES module.
const response = await fetch("https://toolsprimitives.uk/v1/tools/doc.render_pdf/invoke", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.HEELO_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
input: {
"html": "HTML"
},
}),
signal: AbortSignal.timeout(120_000),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());