PDF Generator
Overview
One bundled command prints the PDF and checks it: html2pdf. It runs headless
Chromium on HTML laid out as A4 .page sections (what word_design render and
every PDF/Word template produce), refuses a page under the quality threshold,
merges a slides folder into a 16:9 deck PDF, and converts a finished
.docx / .pptx / .xlsx through LibreOffice when it is installed. Navin
ships the Python libraries; do not check imports or install anything up front.
Text in the PDF must be real text, selectable and searchable, never a page
rendered as a bitmap. html2pdf reads the PDF back and says so when a page has
no text layer.
Language and locale gate (mandatory)
- Before creating or exporting a PDF, require the user to explicitly select the document language. Never infer it from the prompt, UI language, template, names, or location. If absent, ask and stop generation.
- Preserve that language in all visible text and document metadata, including headings, labels, captions, headers/footers, dates, numbers and currencies. Translate every source-template label.
- Format dates, decimal/grouping separators and currency according to the selected locale, consistently across the source and rendered PDF.
- For Arabic and other RTL languages, set
lang and dir="rtl" on the completed HTML, use CSS logical properties and RTL-aware alignment, preserve logical reading order, and use embedded fonts with full glyph coverage (for example Noto Naskh Arabic, Noto Sans Arabic or Amiri). Visually verify shaping and page flow.
Typography & icon rules (mandatory)
- Never use Unicode em dash (U+2014) or en dash (U+2013) in PDF text. Use commas, colons, periods or parentheses instead.
- Never use emoji or generic AI-style icons. Use numbers, plain monochrome glyphs or simple CSS shapes consistent with the design.
HTML document template library
Navin materializes the selected PDF template inside the active workspace
(document.html with A4 .page sections + metadata.json + image.png
preview). When the runtime context contains a "Document Template Attachment",
the user picked one in the WebUI - it is mandatory: copy document.html into
the workspace, keep the design (the <style id="navin-theme"> tokens, the CSS),
replace every visible sample string, add or remove .page sections as the
content needs, then print with html2pdf. Never restyle the template.
Bundled PDF templates: attestation_officielle (certificate, double frame and
seal), contrat_prestation (two-page agreement with payment table and
signatures), fiche_produit (product sheet with banner, benefits, specs and
pricing). Word templates print to PDF with the same command.
Route picker
| Need |
Do |
| Report, letter, proposal, brief |
word_design render --document doc.json -o document.html, then html2pdf document.html -o out.pdf |
| Certificate, agreement, product sheet |
Fill the PDF template's document.html, then html2pdf |
| Deck as PDF |
ppt_design deck ... into slides/, ppt_qa slides/, then html2pdf slides/ -o deck.pdf |
PDF of a finished .docx / .pptx / .xlsx |
html2pdf file.docx -o file.pdf (LibreOffice; the command names the install when it is missing) |
| Batch (N invoices, N certificates) |
One script writes N HTML files from one data file and calls html2pdf on each |
The tools live in the workspace under .navin/resources/tools/ and run with
the interpreter the runtime context names (navin python in a packaged build).
Workflow
- Draft the content; validate facts, numbers and the selected language.
- Lay it out: semantic JSON through
word_design render, or the template's document.html filled by hand. Colours and fonts stay tokens (var(--nv-accent)); never a hex in the body.
- Score the HTML:
word_qa document.html marks each page out of 100 and names what to change (overflow, contrast, tiny text, headings in grids).
- Print:
html2pdf document.html -o out.pdf (--paper letter, --landscape on request). It refuses a failing QA unless the user explicitly accepts the document as is (--force), and it reports pages that spill past A4, empty pages, a missing text layer or a missing <title>.
- Validate the file:
doc_check out.pdf blocks on leftover sample copy, unresolved placeholders, em dashes and emoji.
- Look at it:
preview_document out.pdf previews/ renders the pages and a contact sheet; read the sheet before handing the file over.
- Deliver the PDF path; keep the HTML source beside it so the document stays editable.
Rules
- A4 by default (Letter only on request); embed fonts for AR text (RTL: add
direction: rtl).
- Reading existing PDFs is
pdf-ocr-extractor's job, not this skill's.
- Batch generation: one script + data file, never N manual runs.
- For a legal contract, require configurable governing law and dispute forum fields. Check defined terms, parties, dates, obligations, cross-references, annexes and signatures for internal consistency.
- Keep the final, fully translated HTML source beside every contract PDF so the agreement remains editable and auditable.
- Every generated contract must prominently warn that qualified local counsel must review it before signature (the
contrat_prestation template ships that notice; keep it).
- ReportLab stays available for dense programmatic output (
from reportlab.pdfgen import canvas), but a designed document goes through HTML so the same source can become a DOCX.
1---2name: pdf-generator3description: Generate PDF documents - reports, one-pagers, certificates, agreements, product sheets, quotes - from HTML laid out as A4 pages (Chromium) or from a finished DOCX/PPTX/XLSX (LibreOffice). Use when the deliverable must be a polished PDF.4---56# PDF Generator78## Overview910One bundled command prints the PDF and checks it: `html2pdf`. It runs headless11Chromium on HTML laid out as A4 `.page` sections (what `word_design render` and12every PDF/Word template produce), refuses a page under the quality threshold,13merges a slides folder into a 16:9 deck PDF, and converts a finished14`.docx` / `.pptx` / `.xlsx` through LibreOffice when it is installed. Navin15ships the Python libraries; do not check imports or install anything up front.1617Text in the PDF must be real text, selectable and searchable, never a page18rendered as a bitmap. `html2pdf` reads the PDF back and says so when a page has19no text layer.2021## Language and locale gate (mandatory)2223- Before creating or exporting a PDF, require the user to explicitly select the document language. Never infer it from the prompt, UI language, template, names, or location. If absent, ask and stop generation.24- Preserve that language in all visible text and document metadata, including headings, labels, captions, headers/footers, dates, numbers and currencies. Translate every source-template label.25- Format dates, decimal/grouping separators and currency according to the selected locale, consistently across the source and rendered PDF.26- For Arabic and other RTL languages, set `lang` and `dir="rtl"` on the completed HTML, use CSS logical properties and RTL-aware alignment, preserve logical reading order, and use embedded fonts with full glyph coverage (for example Noto Naskh Arabic, Noto Sans Arabic or Amiri). Visually verify shaping and page flow.2728## Typography & icon rules (mandatory)2930- Never use Unicode em dash (U+2014) or en dash (U+2013) in PDF text. Use commas, colons, periods or parentheses instead.31- Never use emoji or generic AI-style icons. Use numbers, plain monochrome glyphs or simple CSS shapes consistent with the design.3233## HTML document template library3435Navin materializes the selected PDF template inside the active workspace36(`document.html` with A4 `.page` sections + `metadata.json` + `image.png`37preview). When the runtime context contains a "Document Template Attachment",38the user picked one in the WebUI - it is mandatory: copy `document.html` into39the workspace, keep the design (the `<style id="navin-theme">` tokens, the CSS),40replace every visible sample string, add or remove `.page` sections as the41content needs, then print with `html2pdf`. Never restyle the template.4243Bundled PDF templates: `attestation_officielle` (certificate, double frame and44seal), `contrat_prestation` (two-page agreement with payment table and45signatures), `fiche_produit` (product sheet with banner, benefits, specs and46pricing). Word templates print to PDF with the same command.4748## Route picker4950| Need | Do |51|------|----|52| Report, letter, proposal, brief | `word_design render --document doc.json -o document.html`, then `html2pdf document.html -o out.pdf` |53| Certificate, agreement, product sheet | Fill the PDF template's `document.html`, then `html2pdf` |54| Deck as PDF | `ppt_design deck ...` into `slides/`, `ppt_qa slides/`, then `html2pdf slides/ -o deck.pdf` |55| PDF of a finished `.docx` / `.pptx` / `.xlsx` | `html2pdf file.docx -o file.pdf` (LibreOffice; the command names the install when it is missing) |56| Batch (N invoices, N certificates) | One script writes N HTML files from one data file and calls `html2pdf` on each |5758The tools live in the workspace under `.navin/resources/tools/` and run with59the interpreter the runtime context names (`navin python` in a packaged build).6061## Workflow62631. Draft the content; validate facts, numbers and the selected language.642. Lay it out: semantic JSON through `word_design render`, or the template's `document.html` filled by hand. Colours and fonts stay tokens (`var(--nv-accent)`); never a hex in the body.653. Score the HTML: `word_qa document.html` marks each page out of 100 and names what to change (overflow, contrast, tiny text, headings in grids).664. Print: `html2pdf document.html -o out.pdf` (`--paper letter`, `--landscape` on request). It refuses a failing QA unless the user explicitly accepts the document as is (`--force`), and it reports pages that spill past A4, empty pages, a missing text layer or a missing `<title>`.675. Validate the file: `doc_check out.pdf` blocks on leftover sample copy, unresolved placeholders, em dashes and emoji.686. Look at it: `preview_document out.pdf previews/` renders the pages and a contact sheet; read the sheet before handing the file over.697. Deliver the PDF path; keep the HTML source beside it so the document stays editable.7071## Rules7273- A4 by default (Letter only on request); embed fonts for AR text (RTL: add `direction: rtl`).74- Reading existing PDFs is `pdf-ocr-extractor`'s job, not this skill's.75- Batch generation: one script + data file, never N manual runs.76- For a legal contract, require configurable governing law and dispute forum fields. Check defined terms, parties, dates, obligations, cross-references, annexes and signatures for internal consistency.77- Keep the final, fully translated HTML source beside every contract PDF so the agreement remains editable and auditable.78- Every generated contract must prominently warn that qualified local counsel must review it before signature (the `contrat_prestation` template ships that notice; keep it).79- ReportLab stays available for dense programmatic output (`from reportlab.pdfgen import canvas`), but a designed document goes through HTML so the same source can become a DOCX.