PDF Documents Creation (.pdf)
Use the server function create_document({ format: "pdf", title, spec }) to generate a standalone PDF document.
How to fill the spec
Structure First: Organize pages cleanly:
- Clear Title
- Section headings (
level: 1 | 2 | 3) - Paragraphs with
bold: trueor regular text - Bullet lists (
items: string[]) - Tables (
headers: string[],rows: string[][]) - Page numbers (
pageNumbers: true) - Explicit page breaks (
{ "type": "page_break" })
Concise Text: Keep text scannable and well-spaced.
Arabic & RTL Handling:
- For Arabic text, set
rtl: true. - The PDF generator automatically applies Arabic font embedding (Kacst) and right-to-left layout alignment.
- For Arabic text, set
Example Call
{
"format": "pdf",
"title": "Business Proposal Summary",
"spec": {
"rtl": false,
"pageNumbers": true,
"elements": [
{ "type": "heading", "level": 1, "text": "Project Overview" },
{ "type": "paragraph", "text": "This proposal provides an end-to-end roadmap for modernization." },
{ "type": "bullet_list", "items": ["Phase 1: Architecture audit", "Phase 2: Cloud migration"] },
{ "type": "table", "headers": ["Phase", "Duration", "Cost"], "rows": [["Phase 1", "2 weeks", "$8,000"], ["Phase 2", "6 weeks", "$24,000"]] }
]
}
}