Skip to content

Docs / All tools / Loop III: Assistant

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

FieldTypeDescription
htmlRequiredstringThe 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.
pageobjectPage 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_resourcesbooleanLet the document load http(s) images/styles from public hosts.
wait_msintegerChromium only: extra settle time after load, max 15000.
return_databooleanAlso return the PDF as base64 in `data`.
end_user_idstringWhich 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.

FieldTypeDescription
asset_idstringReadable by doc.extract_* as source.asset_id for 30 days. Null when not stored.
bytesintegerSize of the rendered document.
pagesintegerPage count for a PDF. Null for DOCX/XLSX, which have no layout.
content_typestring
filenamestring
engine_usedstring
engine_reasonstringWhy that engine was chosen (PDF only).
render_msinteger
storedbooleanFalse when the document could not be stored for this caller; see `data`.
datastringThe document as base64, when not stored or when asked for.
warningsarray of string
limitationsarray 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())