AI to A4 PDF
Turn supplied content and files into professional print-ready A4 PDFs using local HTML, CSS, Jinja2, and WeasyPrint.
Core Workflow
- Inspect all supplied files and content before drafting.
- Identify the document type, audience, required sections, and missing facts.
- Preserve factual accuracy; do not invent missing commercial, legal, financial, safety, or personal details.
- Choose the closest template from
templates/. - Structure content into semantic document data.
- Render editable HTML with local CSS only.
- Validate A4 page size, margins, headings, tables, images, long text, and page breaks.
- Render the PDF with WeasyPrint.
- Inspect the output for overflow, blank pages, clipped text, broken tables, and poor page breaks.
- Regenerate until the HTML and PDF pass validation.
- Return both the editable HTML path and final PDF path.
- Clearly report missing, unreadable, uncertain, or excluded source information.
Load References When Needed
- Use
references/document-design-guide.mdfor layout, hierarchy, template selection, and report components. - Use
references/print-css-guide.mdfor WeasyPrint paged-media CSS, tables, page numbers, headers, and page-break rules. - Use
references/supported-inputs.mdfor JSON, YAML, Markdown, text, images, and presentation handout inputs. - Use
references/troubleshooting.mdwhen rendering fails or the PDF has overflow, clipped text, blank pages, or bad pagination. - Use
references/security-and-privacy.mdfor confidential documents, local processing, path safety, temporary files, and untrusted HTML.
Commands
python scripts/generate_pdf.py --input examples/professional-report/input.json --template professional-report --output output/report.pdf
ai-to-a4-pdf build examples/quotation-comparison/input.json --template quotation-comparison --output output/quotation.pdf
Guardrails
- Operate locally by default; never upload source files without explicit user approval.
- Do not use remote CDNs, Google Fonts, JavaScript, or live internet resources during PDF rendering.
- Escape untrusted content by default.
- Do not log secrets, tokens, passwords, or private source content.
- Do not treat commercial tender evaluation as technical, legal, safety, or background due diligence unless source evidence supports it.