html-to-pdf
Skill14 starsChanged 31 days agoMITView on GitHub
Builds polished PDF documents (one-pagers, reports, guides, proposals, briefs) as HTML and CSS with exact page layout, renders them with headless Chromium through Playwright, then checks every page as an image before handing the file over. Fixed page sizes, controlled page breaks, no split tables, no orphan headings, a page count you can promise. Use when someone says \"make a PDF\", \"turn this into a PDF report\", \"make a one-pager\", \"PDF version of this doc\", \"export this as a printable guide\", \"it has to fit on two pages\" or \"the PDF layout is broken\".
- Installs packages
10 other projects use a version of this.
Adopted by
Most recently taken up by
- israelsaba/html-to-pdf-skilltheir own version, first seen Oct 13, 2026
- t0ddharris/compound-marketingtheir own version, first seen Oct 8, 2026
- yugasun/skillstheir own version, first seen Jun 24, 2026
- yqdaddy/html-to-pdf-skilltheir own version, first seen Jun 23, 2026
- genecheung/claude-skillstheir own version, first seen Jun 9, 2026
- fulgur-rs/agent-skillstheir own version, first seen Apr 23, 2026
Other versions10 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 10
- atypica-ai/marketing-skills★ 44same name
- yugasun/skills★ 3same name
- israelsaba/html-to-pdf-skill★ 1same name
- jamesxjz/html-to-pdf-agent-skill★ 1same name
- t0ddharris/compound-marketing★ 1same name
- arbones/claude-skills★ 0same name
- callingcard1973/claude-skills★ 0same name
- fulgur-rs/agent-skills★ 0same name
- genecheung/claude-skills★ 0same name
- yqdaddy/html-to-pdf-skill★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository63 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- board-advisorSkill
- bottleneck-removalSkill
- business-auditSkill
- business-starterSkill
- competitor-researchSkill
- founder-independenceSkill
- hand-it-offSkill
- happy-customerSkill
- hiring-replacementSkill
- meeting-follow-upSkill
- monday-numbersSkill
- new-hireSkill
- no-meeting-mondaySkill
- obsidian-brainSkill
- ops-deskSkill
- safe-resaleSkill
- spreadsheet-dashboardSkill
- warm-leadSkill
- downloadable-asset-engineeringSkill
- linux-server-opsSkill
- precision-pdf-editingSkill
- repo-radarSkill
- secure-credentialsSkill
- security-auditorSkill
- best-timeSkill
- brand-deal-filterSkill
- comment-replySkill
- content-monthSkill
- daily-socialSkill
- dm-closerSkill
- idea-bankSkill
- marketing-teamSkill
- reel-ideationSkill
- reel-scorecardSkill
- trial-postSkill
- viral-breakdownSkill
- youtube-seoSkill
- caption-engineSkill
- content-multiplierSkill
- edit-styleSkill
- footage-ingestSkill
- longform-editSkill
- podcast-repurposeSkill
- raw-to-reelSkill
- ready-to-filmSkill
- reel-captionsSkill
- script-polishSkill
- thumbnail-generatorSkill
- use-local-whisperSkill
- conversion-funnel-auditingSkill
- llms-txtSkill
- seo-agentSkill
- website-designerSkill
- website-devSkill
- be-conciseSkill
- humanizerSkill
- launch-weekSkill
- linkedin-writerSkill
- newsletterSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
7 rules. 0 are common, 5 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 7 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 31
Plan the pages: Before writing HTML, write a one-line outline per page: what goes on page 1, page 2, and so on.
- Very specific: line 52
Use print units (mm, in, pt) for page boxes, margins and type.
- Very specific: line 53
Keep things whole: break-inside: avoid on cards, metric grids, callouts, figures and table rows.
- Distinctive: line 60
No empty pages, and the last page should not be mostly blank.
- Distinctive: line 64
Run the script, then check each page image for:
- Distinctive: line 70
Images and charts: every image loaded, every SVG drawn, labels readable.
- Distinctive: line 77
After any fix, even a one-line CSS change, re-render the PDF and regenerate every PNG before saying it passed.
“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
HTML to PDF
Most converters give you a PDF but not control: a half-empty last page, a lone heading at the bottom, a table cut in half. This skill writes the document as HTML and CSS, prints it with headless Chromium, and looks at every page before calling it done.
What it does
- Turns content (notes, a draft, data, a brief) into a single self-contained HTML file laid out page by page.
- Renders it to PDF with headless Chromium. No window ever opens.
- Exports each page as a PNG, checks it by eye and by script, fixes problems and renders again.
- Hands over the PDF with its page count, size and the QA it passed.
What you need
- Python 3.9 or newer.
- Playwright and Chromium:
pip install playwright pypdf pypdfium2 python -m playwright install chromiumpypdfium2is only for PNG export. If it is missing, the script falls back topdftoppmfrom poppler. - The content, the audience, the paper size (A4 or Letter) and a target page count. If any are missing and cannot be inferred, ask once; otherwise default to A4 and the shortest length that fits.
- Puppeteer works too (same engine, same CSS).
Steps
- Plan the pages. Before writing HTML, write a one-line outline per page: what goes on page 1, page 2, and so on. A one-pager is one page. A report is usually a cover plus 2 to 6 pages. Decide the page count now, not after rendering.
- Copy the template. Start from
templates/document.html. It has a cover page, a content page, a key-number grid, two columns, a table, a callout and a footer, all in neutral styling with[placeholders]. Swap the colour and font tokens in:rootif the reader has a brand. - Fill one
.pageblock per planned page. Real content, not lorem ipsum. Lead with the point. - Render:
It prints the page count, file size and PNG paths, and warns about overflowing content, fonts that did not load, broken images, and a mismatch betweenpython scripts/render_pdf.py report.html out/report.pdf --png-dir qa/ --expect-pages 3.pageboxes and PDF pages. Add--strictto make any warning a failure. - Look at every PNG against the QA list below. The script catches overflow; only your eyes catch ugly.
- Fix and render again. Repeat steps 4 and 5 until every page passes. Old PNGs are cleared on each run so you never review a stale render.
Layout rules
Two ways to lay out pages. Pick one per document.
- Fixed pages (default, used by the template). Each
<div class="page">is exactly one sheet:widthandheightset to the paper size,overflow: hidden,break-after: page. You decide what goes on each page, so the page count is guaranteed. Best for one-pagers, covers, proposals and anything with a promised length. - Flowing text. For long prose (guides, manuals) let content flow and use
@page { size: A4; margin: 20mm; }with break rules. Page count is then an output, not an input, so check it every render.
Always:
- Set the paper size once, in
@page { size: A4; margin: 0; }(orLetter), and render withprefer_css_page_size=True. Letter is 8.5in by 11in, A4 is 210mm by 297mm. Never mix them. - Use print units (
mm,in,pt) for page boxes, margins and type. Body text 10 to 11pt, captions 8pt, nothing under 7.5pt. - Keep things whole:
break-inside: avoidon cards, metric grids, callouts, figures and table rows.break-after: avoidon headings so a heading never ends a page. orphans: 3; widows: 3;on paragraphs so a single line is never stranded.- Tables:
thead { display: table-header-group; }repeats the header if a long table must continue. Otherwise move the whole table to the next page or split it at a logical row. - Turn on
print-color-adjust: exactand render with print backgrounds, or tinted panels vanish. - Self-contained file: inline CSS, inline SVG charts, images as local files or data URIs. Every remote font or image is a chance to render with a fallback.
- Fonts: system font stacks are safest. If you load a web font, keep the fallback stack and check the script's font warnings.
- Pin footers with
margin-top: autoin a flex column, not absolute positioning, so overflow is detectable. - No empty pages, and the last page should not be mostly blank. Consolidate or cut copy.
QA
Run the script, then check each page image for:
- Overflow: text clipped at the bottom or right edge, or content hidden under the footer.
- Orphans: a heading at the foot of a page with its text on the next, or one stray line of a paragraph.
- Cut tables and cards: rows, metric grids or callouts split across pages.
- Fonts: the intended typeface, not a Times fallback. The script lists any font that failed to load.
- Images and charts: every image loaded, every SVG drawn, labels readable.
- Contrast: bold text, links and labels inside dark or tinted panels are still visible. A global text colour often hides nested
strongon dark cards. - Page count: matches the plan. Use
--expect-pages Nso the script fails if it drifts. - Folios and footers: page numbers correct ("2 / 3"), no stale totals left from an earlier draft.
- File size: a few MB at most for email (the script warns over 10 MB). Resize large photos before embedding.
- Text check (optional): extract the text (
pdftotext -layout) and search for leftover[placeholders], typos in names and figures that must match the source.
After any fix, even a one-line CSS change, re-render the PDF and regenerate every PNG before saying it passed. Screenshots from before a fix prove nothing.
Output
- The PDF, named in kebab-case for what it is:
q3-board-report.pdf,onboarding-guide.pdf. - The HTML source next to it, so the next edit is a re-render.
- A short note: page count, paper size, file size, and anything you could not verify.
- QA images stay out of the deliverable folder.
Honest limits
- Chromium print is not a typesetting engine. Hyphenation, footnotes and running headers that change by chapter are weak. For a book, use a dedicated tool.
- Fixed pages hide overflow by design (
overflow: hidden). That is why the script measures it; never skip the warnings. break-inside: avoidis a request. A block taller than a page will still split.- Remote fonts and images can fail silently on slow networks. Self-contain the file when it matters.
- Visual QA needs a model or person that can see images.
- It produces a print PDF, not an accessible tagged PDF or a fillable form.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

