BosskuAI Document Compilation
Use this skill to build or debug a pipeline that turns a web preview or arbitrary YAML/JSON data into print-ready, paged documents (invoices, reports, CVs, proposals) with predictable layout.
How this differs from nearby skills
odl-pdf: extracting structured text, tables, and OCR from existing PDFs. This skill creates PDFs.
markitdown: converting Office/PDF/HTML into Markdown, the reverse direction.
accessibility: WCAG for web UI; here only the PDF tagging and metadata part.
e2e-testing: Playwright test suites; this skill uses Playwright only as a PDF renderer.
Part A: HTML to PDF
- One template. Render the PDF from a snapshot of the same hydrated UI the user previews, not from a second backend template that can drift.
- Set page size explicitly with
@page { size; margin }. Check the installed browser's support: CSS variables inside @page have not worked in Chromium, so inject concrete values from a runtime style element.
- Compute sizes in one place (mm, pt, px at 96 DPI) and keep a small table for A4, Letter, Legal, and custom sizes. Validate custom sizes are finite and positive.
- Avoid blank trailing pages: sub-pixel rounding can push content a fraction over the page. Test with a small height buffer on the page container and check the page count on long and short inputs.
- Keep text and shapes as vectors. In print CSS, avoid
filter, backdrop-filter, and heavy effects that can make the engine rasterise; verify by inspecting the output.
- Wait for fonts and images before printing (for example
document.fonts.ready). Use the headless renderer's PDF call, not window.print().
- Editor preview: keep the sheet at fixed physical size and zoom with a transform so line breaks match the PDF.
- Throughput: reuse a warm browser and isolated contexts, cap concurrency, recycle after a job count, and drain in-flight jobs before shutdown. Measure your own latency; do not trust quoted numbers.
- Accessibility: emit a tagged PDF, use real headings, lists, table headers, and image alt text. If PDF/A or PDF/UA is required, post-process metadata and validate with a dedicated checker.
- Audit the output: page count, selectable text, font ToUnicode maps, no full-page raster images.
Part B: schema-agnostic data to layout
- Parse YAML with a library that keeps source positions and comments; do not round-trip with a plain dump.
- Never drop unknown keys. Render them with a generic block layout.
- Infer a layout per node from its shape (list of similar records, key-value map, short tags, long prose, dated items). Make inference a replaceable function with an explicit override.
- Store view settings (colours, ordering, hidden flags) in a separate sidecar file keyed by stable paths, not inside the user's data.
- Two-way editing: tag each edit with its origin to avoid update loops, and mutate the syntax tree in place to preserve comments.
- Paged rules: headings
break-after: avoid, cards and rows break-inside: avoid, and a fallback page break when a block exceeds a page.
Guardrails
- Sanitise snapshots: strip scripts, iframes, and inline event handlers. When inlining assets, allow only https and a domain allow-list to prevent SSRF.
- Bound iterative solvers (max iterations) to avoid denial of service.
- Browser flags like
--no-sandbox reduce isolation; use only where the container requires it.
- Check current Playwright, Chromium, and PDF-library docs for option names.
- Compliance claims (PDF/UA, PDF/A, Section 508) need a validator run and human review; documents with legal or clinical content need their own review.
Output format
Input and target: [source, page size, accessibility level]
Pipeline: [snapshot, render, post-process, audit]
Layout rules: [page geometry, break rules, fallbacks]
Throughput and limits: [pool size, recycle, timeouts]
Verification: [page count, text selectable, validator result]
Open risks: [list]
The shared quality bar: ../../references/checklists/engineering-quality-bar.md.
Adapted from agency-agents/engineering/engineering-pdf-engine-architect.md and engineering-universal-document-compiler.md (agency-agents, MIT).
1---2name: bosskuai-document-compilation3description: "Use when generating PDFs from HTML or structured data: deterministic page sizes, no blank trailing pages, Playwright browser pools, tagged accessible PDFs, and schema-agnostic YAML/JSON to paged-document layouts."4metadata:5 source: https://skillmd.com/skills/wankimmy/bosskuai-document-compilation6---78# BosskuAI Document Compilation910Use this skill to build or debug a pipeline that turns a web preview or arbitrary YAML/JSON data into print-ready, paged documents (invoices, reports, CVs, proposals) with predictable layout.1112## How this differs from nearby skills1314- **`odl-pdf`**: extracting structured text, tables, and OCR from existing PDFs. This skill creates PDFs.15- **`markitdown`**: converting Office/PDF/HTML into Markdown, the reverse direction.16- **`accessibility`**: WCAG for web UI; here only the PDF tagging and metadata part.17- **`e2e-testing`**: Playwright test suites; this skill uses Playwright only as a PDF renderer.1819## Part A: HTML to PDF20211. One template. Render the PDF from a snapshot of the same hydrated UI the user previews, not from a second backend template that can drift.222. Set page size explicitly with `@page { size; margin }`. Check the installed browser's support: CSS variables inside `@page` have not worked in Chromium, so inject concrete values from a runtime style element.233. Compute sizes in one place (mm, pt, px at 96 DPI) and keep a small table for A4, Letter, Legal, and custom sizes. Validate custom sizes are finite and positive.244. Avoid blank trailing pages: sub-pixel rounding can push content a fraction over the page. Test with a small height buffer on the page container and check the page count on long and short inputs.255. Keep text and shapes as vectors. In print CSS, avoid `filter`, `backdrop-filter`, and heavy effects that can make the engine rasterise; verify by inspecting the output.266. Wait for fonts and images before printing (for example `document.fonts.ready`). Use the headless renderer's PDF call, not `window.print()`.277. Editor preview: keep the sheet at fixed physical size and zoom with a transform so line breaks match the PDF.288. Throughput: reuse a warm browser and isolated contexts, cap concurrency, recycle after a job count, and drain in-flight jobs before shutdown. Measure your own latency; do not trust quoted numbers.299. Accessibility: emit a tagged PDF, use real headings, lists, table headers, and image alt text. If PDF/A or PDF/UA is required, post-process metadata and validate with a dedicated checker.3010. Audit the output: page count, selectable text, font ToUnicode maps, no full-page raster images.3132## Part B: schema-agnostic data to layout33341. Parse YAML with a library that keeps source positions and comments; do not round-trip with a plain dump.352. Never drop unknown keys. Render them with a generic block layout.363. Infer a layout per node from its shape (list of similar records, key-value map, short tags, long prose, dated items). Make inference a replaceable function with an explicit override.374. Store view settings (colours, ordering, hidden flags) in a separate sidecar file keyed by stable paths, not inside the user's data.385. Two-way editing: tag each edit with its origin to avoid update loops, and mutate the syntax tree in place to preserve comments.396. Paged rules: headings `break-after: avoid`, cards and rows `break-inside: avoid`, and a fallback page break when a block exceeds a page.4041## Guardrails4243- Sanitise snapshots: strip scripts, iframes, and inline event handlers. When inlining assets, allow only https and a domain allow-list to prevent SSRF.44- Bound iterative solvers (max iterations) to avoid denial of service.45- Browser flags like `--no-sandbox` reduce isolation; use only where the container requires it.46- Check current Playwright, Chromium, and PDF-library docs for option names.47- Compliance claims (PDF/UA, PDF/A, Section 508) need a validator run and human review; documents with legal or clinical content need their own review.4849## Output format5051```text52Input and target: [source, page size, accessibility level]53Pipeline: [snapshot, render, post-process, audit]54Layout rules: [page geometry, break rules, fallbacks]55Throughput and limits: [pool size, recycle, timeouts]56Verification: [page count, text selectable, validator result]57Open risks: [list]58```5960The shared quality bar: `../../references/checklists/engineering-quality-bar.md`.6162Adapted from agency-agents/engineering/engineering-pdf-engine-architect.md and engineering-universal-document-compiler.md (agency-agents, MIT).