Productivity and leadership

HTML to PDF

Print-ready PDFs with clean breaks, embedded fonts and a check report

Turns HTML or finished content into a print and send-ready PDF in A4 or US Letter: print CSS with @page, clean page breaks, repeated table headers, embedded fonts and page numbers. Every page is checked visually, and a check report lists fixed errors, limitations and assumptions.

How to install it

Install the ZIP in Claude, ChatGPT or Manus. Use the SKILL.md for Gemini, Mistral, Perplexity and projects.

Version
2.0.0
Updated
Length
11 chapters · approx. 15 min read
Format
SKILL.md (Markdown, English)
License
CC BY-NC-ND 4.0

When this skill kicks in

  • Make a PDF out of this HTML
  • I need the proposal as a print-ready PDF
  • The table is split across two pages in the PDF
  • Write print CSS for this report
  • Why is page 4 of the PDF blank?
  • The handout should go out as an A4 PDF with page numbers
  • The font in the PDF is wrong
  • Export this as US Letter

Requirements

HTML outputCode executionFile upload

Works in any chat tool with these capabilities.

PDFprint CSSHTMLdocumentsWeasyPrintA4 and Letter

What's inside

  1. 01When this skill applies
  2. 02When not
  3. 03What I need
  4. 04Procedure
  5. 05Expertise and rules
  6. 06Edge cases
  7. 07Output format
  8. 08Example
  9. 09Anti-patterns
  10. 10Quality check before delivery
  11. 11Requirements
Sample output

Input: "Turn my HTML proposal for Sample Ltd (fictional) into a PDF for email. Our house font is Source Sans 3, the files are in the fonts folder."

PDF done: proposal-sample-ltd-2026-11-03.pdf · 6 pages · A4 portrait · WeasyPrint · 1.4 MB

Check pointResult
Page format and marginsok, 595 × 842 pt, margins 20/18/22/18 mm
Fonts embedded (pdffonts)ok, SourceSans3 Regular and Bold, emb yes
Text extractable (pdftotext)ok
Breaks, blank pages, headings at the bottom of a pageok after fix 2
Tables (header repeated, no split rows)ok after fix 1
Images (resolution, sharpness)finding: logo on page 1 slightly soft
Visually checkedall 6 pages

Fixed errors:

  1. Pages 3 to 4: header of the price table "Item / Quantity / Price" missing on page 4. Cause: the header row was the first row in the tbody. Fix: real thead with display: table-header-group, rendered again, all 6 pages checked again.
  2. Page 5: subheading "Payment terms" stood alone at the bottom of the page. Fix: break-after: avoid on h2.

Print CSS (excerpt):

@page { size: A4; margin: 20mm 18mm 22mm 18mm;
  @bottom-center { content: counter(page) " / " counter(pages); font-size: 8pt; } }
@page :first { @bottom-center { content: none; } }
h1, h2, h3 { break-after: avoid; }
thead { display: table-header-group; }
tr { break-inside: avoid; }

Open limitations: the logo is a PNG 300 px wide at a print width of 50 mm, so 152 dpi. Just enough for office printing, a print shop would need 591 px. Recommendation: embed the logo as SVG.

Assumptions: [ASSUMPTION: purpose email, recipient in the UK so A4 rather than Letter, no page number on the title page]

Shortened example with fictional data. Real results depend on your input and tool.

Full instructions

The complete file content, identical to the download.

HTML to PDF

This skill turns HTML (or content that is first set as HTML for this purpose) into a PDF that can be printed, emailed and archived: real, searchable text, embedded fonts, clean breaks, page numbers and a visual check of every single page. For anyone who wants to make proposals, reports, handouts, certificates or one-pagers ready to send without a layout program.

When this skill applies

  • An HTML document (report, handout, proposal, certificate, one-pager, e-book chapter) should go out as a PDF.
  • An existing PDF from the browser has errors: cut-off text, blank pages, split tables, wrong font, missing backgrounds.
  • Someone needs print CSS for an existing web page or template.
  • Content from another skill (offerte-generator, rechnungs-generator, visual-page-builder) should be printed.

When not

  • Working out the content, line items and prices of a quote or invoice: offerte-generator, rechnungs-generator. Then come here for the PDF.
  • Slides for presenting: slide-decks (has its own landscape print mode).
  • Carousel PDF for LinkedIn in 4:5 format: linkedin-carousel-pdf.
  • Explainer page for the web: visual-page-builder. Process diagram: workflow-visualizer.
  • Print-ready file for a print shop with CMYK, bleed and colour profile: the skill delivers an RGB file with bleed (see Edge cases) and says clearly that the print shop does the preflight.
  • Fillable PDF forms or digital signatures: not possible from HTML, refer to a PDF tool.

What I need

Required: the HTML (file, code or link to a local file) or the content to be set.

Optional: format (default A4 portrait; US and Canada usually Letter), margins, header and footer, whether page numbers are wanted, font files (WOFF2, TTF, OTF), logo as SVG, purpose (email, office printer, print shop, archive), file name.

Clarifying-question rule: Ask at most one compact question, and only if neither HTML nor content is available. Solve everything else with visible assumptions, for example [ASSUMPTION: A4 portrait, margins 20/18 mm, page number bottom centre, purpose email]. If the recipient is clearly in the US or Canada, assume Letter instead of A4. If a font file is missing, do not ask, use a system font and note it in the report.

Procedure

  1. Determine the purpose. Email and office printing (default), print shop or archive. The purpose controls resolution, bleed and PDF variant (table "Purpose" below).
  2. Check the environment. If code execution with a renderer is available (WeasyPrint, Chromium, Playwright): render yourself. If not: fallback route (see Requirements) and say so in the report.
  3. Choose the renderer using the decision table. If the HTML needs JavaScript to build itself (charts, data from a script): Chromium or Playwright, never WeasyPrint.
  4. Clean up the HTML. Semantics (h1 to h3, table with thead, figure), hide navigation, buttons, cookie banners and videos in @media print, make external resources local.
  5. Add print CSS following the skeleton below. Set break rules deliberately, not across the board.
  6. Embed fonts and images. Local font files via @font-face, check images for print size (formula below).
  7. Render.
  8. Check automatically. Page count, embedded fonts, extractable text (commands below).
  9. Visually check every page as an image, with the checklist. If an error appears: look for the cause in the error table, fix it, render again, check all pages again.
  10. Hand over with the file name and check report in the output format.

Expertise and rules

Purpose controls the settings

PurposeImagesBleedPDF variantTarget size
Email, screen, office printer150 dpi relative to print sizenonestandard PDFunder 5 MB
Print shop300 dpi3 mm all round (US print shops often 0.125 in, about 3.2 mm) if areas run to the edgestandard PDF, preflight by the print shopas agreed
Archive150 dpinonePDF/A (e.g. PDF/A-3b), validate with veraPDFunder 10 MB

Image width in pixels = width in the document in mm / 25.4 × dpi. Example: image across the text width of 174 mm at 150 dpi: 174 / 25.4 × 150 = 1,028 px. At 300 dpi: 2,055 px. Do not upscale smaller images, set them smaller instead.

Paper formats

FormatSizeIn points@page sizeCommon in
A4 portrait210 × 297 mm595 × 842 ptA4Europe, UK, most of the world
US Letter portrait8.5 × 11 in (216 × 279 mm)612 × 792 ptletterUS, Canada, parts of Latin America
US Legal8.5 × 14 in (216 × 356 mm)612 × 1008 ptlegalUS legal documents

Letter is wider and shorter than A4. A layout built for A4 loses about 18 mm of height on Letter: check page breaks again after switching, and do not just scale. If one PDF must work for both (international recipients), use a text width of at most 170 mm and margins of at least 20 mm, then it prints on both without cropping.

Renderer decision

SituationRenderer
Static HTML, page numbers in header or footer, running chapter names, PDF/A, crop marksWeasyPrint
JavaScript builds content, modern layouts with grid and flex, web fonts via document.fontsChromium headless or Playwright
Only a browser available, no code executionthe browser's print dialog (fallback)

Known differences, as of 11/2026, check for updates when versions change:

  • WeasyPrint does not run JavaScript and supports @page margin boxes (@top-center, @bottom-right), counter(page), counter(pages), string-set for running chapter names, bleed and marks: crop.
  • Chromium supports @page margin boxes only in newer versions (from about version 131) [CHECK: version in the environment]. In older versions, set page numbers via the header and footer template of Playwright or Puppeteer.
  • Firefox and Safari do not implement @page margin boxes. In the browser fallback, therefore, never promise a page number from CSS.
  • Playwright and Puppeteer take over @page size only with preferCSSPageSize: true, otherwise the format from the call applies.

Print CSS skeleton

@page {
  size: A4;                       /* 210 × 297 mm; landscape: A4 landscape; US: letter */
  margin: 20mm 18mm 22mm 18mm;    /* top right bottom left */
  @bottom-center { content: counter(page) " / " counter(pages); font: 8pt/1 var(--font-text); color: #555; }
}
@page :first { @bottom-center { content: none; } }   /* title page without page number */

:root { color-scheme: light; --font-text: "Source Sans 3", "Helvetica Neue", Arial, sans-serif; }
html { font: 10.5pt/1.45 var(--font-text); color: #111; background: #fff; }
p, li { orphans: 3; widows: 3; }
h1, h2, h3 { break-after: avoid; page-break-after: avoid; }
table, figure, .karte, blockquote { break-inside: avoid; page-break-inside: avoid; }
tr { break-inside: avoid; }
thead { display: table-header-group; }   /* table header on every page */
tfoot { display: table-footer-group; }
section.kapitel { break-before: page; }
section.kapitel:first-of-type { break-before: auto; }  /* prevents a blank first page */
img, svg { max-width: 100%; height: auto; }
a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #555; }
.flaeche { print-color-adjust: exact; -webkit-print-color-adjust: exact; }

@media print {
  nav, button, .cookie, video, iframe, .nur-bildschirm { display: none !important; }
  .raster { display: block; }   /* switch grid and flex to block for print */
}

The class names (kapitel = chapter, karte = card, flaeche = filled area, raster = grid, nur-bildschirm = screen only) are examples; use the class names of the actual document.

Rules for it:

  • Sizes in mm, in, pt or %. px only for hairlines (0.5pt is better).
  • Font sizes: body text 10 to 11.5 pt, footnotes and footer at least 7.5 pt, line height 1.35 to 1.5. Line length 60 to 80 characters; with wider columns set two columns or enlarge the margins.
  • Margins: at least 15 mm, default 20 mm top and bottom. For hole punching or binding, 25 mm on the left.
  • Break rules work unreliably in flex and grid containers. Set containers that run across pages to display: block in print.
  • Put break-inside: avoid only on elements shorter than half a page. Longer elements may break, otherwise half-empty pages appear.
  • Do not write out internal links (href="#..."), only external ones.
  • Avoid dark solid areas across whole pages. If the template has a dark mode, switch to light for print (color-scheme: light).
  • Do not embed text that must be in the PDF as an image. Text stays text (searchable, copyable, more accessible).

Fonts

@font-face {
  font-family: "Source Sans 3";
  src: url("fonts/SourceSans3-Regular.woff2") format("woff2"),
       url("fonts/SourceSans3-Regular.ttf") format("truetype");
  font-weight: 400; font-style: normal;
}
  • Font files locally next to the HTML or as a data: URI. No CDN at render time, because without network the renderer silently falls back to a substitute font.
  • For WeasyPrint prefer TTF or OTF, WOFF2 only if the environment demonstrably renders it.
  • One @font-face rule for every weight used (400, 700, italic). If the bold weight is missing, the renderer creates an artificially bold variant.
  • Check the licence: free fonts (SIL Open Font License) may be embedded. With purchased fonts, not every licence allows embedding [CHECK: licence of the client font].
  • Check after rendering with pdffonts: every font must show "yes" in the "emb" column. If an unexpected font shows up (e.g. "DejaVuSans"), a fallback has kicked in.

Headers and footers

  • With WeasyPrint and newer Chromium: @page margin boxes. Running chapter name: h2 { string-set: kapitel content(); } and @top-right { content: string(kapitel); } (WeasyPrint).
  • With Playwright: displayHeaderFooter: true and footerTemplate. The template does not inherit page styles: set font size and colour explicitly there (font-size: 8pt), otherwise the text is tiny. Placeholders: <span class="pageNumber"></span>, <span class="totalPages"></span>, <span class="title"></span>, <span class="date"></span>. The bottom page margin must be large enough for the footer.
  • Always turn off the browser's own headers and footers (date, file path).

Commands

# WeasyPrint
weasyprint input.html out.pdf
weasyprint --pdf-variant pdf/a-3b input.html out-archive.pdf

# Chromium headless (newer versions)
chromium --headless --disable-gpu --no-pdf-header-footer \
  --print-to-pdf=out.pdf --virtual-time-budget=5000 input.html

# Playwright (Python)
page.goto("file:///path/input.html"); page.wait_for_load_state("networkidle")
page.evaluate("document.fonts.ready")
page.pdf(path="out.pdf", prefer_css_page_size=True, print_background=True)

# Check (poppler-utils)
pdfinfo out.pdf            # page count, page size in pt (A4 = 595 × 842, Letter = 612 × 792)
pdffonts out.pdf           # embedded fonts
pdftotext out.pdf - | head # text extractable?
pdftoppm -png -r 80 out.pdf page   # one image per page for the visual check

If chromium is not present, the command is called google-chrome or chrome depending on the system.

Error patterns and causes

Error patternCommon causeFix
Blank page at the start or between chaptersbreak-before: page on the first chapter or set twicelift the rule for the first chapter, only one break per transition
Half a page emptybreak-inside: avoid on a long blockremove the rule or split the block
Text cut off on the rightfixed width in px, white-space: nowrap, wide tablemax-width: 100%, set the table landscape or shorten columns
Table header missing on the next pageno thead, or header as a tr in the tbodyuse a real thead, display: table-header-group
Heading alone at the bottom of a pagebreak-after: avoid missingrule on h1 to h3
Background colours missingprinting without backgroundsprint-color-adjust: exact on the area, enable backgrounds when rendering
Wrong fontweb font not loaded, weight missingembed the font locally, wait for document.fonts.ready
Chart missingJavaScript did not run or ran too brieflyChromium instead of WeasyPrint, increase waiting time
PDF over 10 MBuncompressed photos, PNG for photosphotos as JPEG at quality 80 to 85 at print size
Content shifted after switching A4 to Letterlayout tuned to A4 heightre-check breaks, keep text width at most 170 mm

Regional specifics (Switzerland, Germany, UK, US)

  • Switzerland: A4, sizes in mm. Numbers in German-language documents with an apostrophe as thousands separator (CHF 12'500.00), in English-language documents with a comma (CHF 12,500.00).
  • Letters with window envelopes: match the address block to the window position. In Switzerland the window is usually on the right (standard SN 010130), in Germany on the left (DIN 5008), in the UK (DL and C5 envelopes) and the US (No. 10 envelope) usually on the left [CHECK: exact dimensions for the envelope used]. After rendering, test with a real envelope against the light.
  • Swiss QR-bill: if the document contains a QR payment part, the payment part with receipt is 210 × 105 mm at the bottom edge, never scale it. When printing choose "Actual size" instead of "Fit to page". The QR-bill is designed for A4; on Letter it does not fit cleanly [CHECK]. Content and data of the QR code belong to rechnungs-generator.
  • Archiving of business records: PDF/A is a widely used archive format. Whether it is required for a specific retention obligation is a question for the accountant or tax adviser [CHECK].

Edge cases

  • No code execution: deliver finished HTML with print CSS, plus the instructions for the print dialog (see Requirements). In the report: "Not rendered by me, visual check by you needed", plus the five most important check points.
  • HTML loads content via JavaScript (charts, tables from data): Chromium or Playwright, wait for network idle and document.fonts.ready. If only WeasyPrint is available: write charts into the HTML as SVG beforehand.
  • Very wide table (over 8 columns): chapter on its own landscape page (@page quer { size: A4 landscape; } and .quer { page: quer; }, "quer" = landscape), or split the columns. Never shrink below 7 pt.
  • Print shop requires bleed: in WeasyPrint @page { bleed: 3mm; marks: crop; }, extend full-bleed areas 3 mm beyond the edge. Note: the PDF is RGB, conversion to CMYK and preflight are done by the print shop.
  • Client font without a file: use a system font with a similar feel, name it in the report, do not pretend it is the original font.
  • Very long document (over 80 pages): render in chapters and check samples plus all chapter starts, tables and the last page as images. State in the report which pages were checked visually.
  • Accessibility required (public authority, education): create a tagged PDF (Chromium and Playwright tag in newer versions, WeasyPrint with --pdf-variant pdf/ua-1 [CHECK: version]), language in the lang attribute, alt texts, real headings. Say honestly: a full PDF/UA check needs a checking tool (e.g. PAC).
  • Same document for European and US recipients: either two PDFs (A4 and Letter, file names with -a4 and -letter) or one PDF with the safe text width from "Paper formats". Say which option was chosen.
  • An existing PDF should only be corrected, HTML is missing: PDF editing is not this skill. Offer to set the content again as HTML.

Output format

  1. The file <content>-<recipient>-<YYYY-MM-DD>.pdf (lower case, hyphens, no special characters), e.g. proposal-sample-ltd-2026-11-03.pdf. Without code execution: <name>-print.html plus instructions.
  2. The check report in the chat:
**PDF done:** `<file name>.pdf` · <n> pages · <format> · <renderer> · <file size>

| Check point | Result |
|---|---|
| Page format and margins | ok / finding |
| Fonts embedded (pdffonts) | ok / finding |
| Text extractable (pdftotext) | ok / finding |
| Breaks, blank pages, headings at the bottom of a page | ok / finding |
| Tables (header repeated, no split rows) | ok / finding |
| Images (resolution, sharpness) | ok / finding |
| Visually checked | all <n> pages / pages <list> |

Fixed errors: <numbered list with page, cause, fix, or "none">
Open limitations: <list or "none">
Assumptions: <list or "none">

Example

Input: "Turn my HTML proposal for Sample Ltd (fictional) into a PDF for email. Our house font is Source Sans 3, the files are in the fonts folder."

Handover:

**PDF done:** `proposal-sample-ltd-2026-11-03.pdf` · 6 pages · A4 portrait · WeasyPrint · 1.4 MB

| Check point | Result |
|---|---|
| Page format and margins | ok, 595 × 842 pt, margins 20/18/22/18 mm |
| Fonts embedded (pdffonts) | ok, SourceSans3 Regular and Bold, emb yes |
| Text extractable (pdftotext) | ok |
| Breaks, blank pages, headings at the bottom of a page | ok after fix 2 |
| Tables (header repeated, no split rows) | ok after fix 1 |
| Images (resolution, sharpness) | finding: logo on page 1 blurry |
| Visually checked | all 6 pages |

Fixed errors:
1. Pages 3 to 4: header of the price table missing on page 4. Cause: the header row was the first row in the tbody. Fix: real thead with display: table-header-group.
2. Page 5: "Payment terms" stood alone at the bottom of the page. Fix: break-after: avoid on h2.
Open limitations: the logo is a PNG 300 px wide at a print width of 50 mm (152 dpi), looks slightly soft in print. Replace with SVG.
Assumptions: [ASSUMPTION: purpose email, recipient in the UK so A4, no page number on the title page]

Calculation check: 50 mm / 25.4 × 150 dpi = 295 px needed, 300 px available (152 dpi), so just enough for office printing, but not for a print shop (300 dpi needs 591 px).

Anti-patterns

  • Delivering screenshots of the page as a PDF (text not searchable, not accessible, blurry).
  • Looking only at the first page and reporting "looks good".
  • Putting break-inside: avoid on every div or section.
  • Loading web fonts from a CDN at render time.
  • Fixed pixel widths in the print layout.
  • Promising page numbers from CSS when the renderer cannot do them.
  • Printing a dark-mode layout with black solid areas as is without asking.
  • Scaling an A4 layout onto Letter (or vice versa) instead of re-checking the breaks.
  • Claiming the PDF is PDF/A or accessible without validation.

Quality check before delivery

  • Purpose determined, renderer chosen using the decision table
  • @page set with format (A4 or Letter) and margins, page size confirmed in pdfinfo
  • Break rules targeted, no blank page, no orphaned heading
  • Tables with a real thead, header visible on following pages
  • All fonts embedded, no unexpected substitute font
  • Text extractable, no content as images
  • Image resolution fits the purpose (formula applied)
  • Every page checked as an image, or checked pages named in the report
  • File name follows the scheme, report complete, assumptions marked
  • Consistent spelling (UK or US), straight quotation marks, no dashes

Requirements

  • Code execution with a renderer (WeasyPrint, Chromium or Playwright) and poppler-utils for checking: full process with visual check.
  • Without code execution (fallback): deliver print-ready HTML, as a file or as a code block with the note "save as .html". Instructions for Chrome or Edge: open the file, Ctrl+P (Mac: Cmd+P), destination "Save as PDF", paper size A4 or Letter, margins "Default" (then the margins from @page apply), scale 100 %, "Headers and footers" off, "Background graphics" on. Note in the report that it was not rendered and checked by you, and ask the person to look at pages with tables and chapter starts.
  • Without an image view of the pages: still run the automatic checks (pdfinfo, pdffonts, pdftotext) and enter "Visually checked: no" in the report.
  • Upload (optional) for HTML, fonts and logo. Without upload: paste the code, use a system font.

Version 2.0.0 · Last updated: 3 November 2026 · skills.fragroger.ai · Roger Basler de Roca

License: CC BY-NC-ND 4.0 with additional permission (CC+): use in companies and for client work is allowed, adaptation for your own use is allowed. Not allowed: selling, bundling, publishing modified versions. Details: https://skills.fragroger.ai/lizenz

How to install this skill

A skill is a folder with a SKILL.md file. Once installed, your AI tool knows the skill permanently and pulls up the instructions by itself whenever a request fits. Pick your tool:

File: download the ZIP

Pro, Max, Team or Enterprise plan. Code execution and file creation must be turned on. On Team and Enterprise, your organization must allow skills.

  1. 1

    Download the ZIP

    Click "Download ZIP" above. Do not unzip html-to-pdf.zip.

  2. 2

    Open settings

    In Claude, click your name at the bottom left, then Settings. Open Capabilities and scroll to the Skills section.

  3. 3

    Upload the skill

    Click "Upload skill" and select html-to-pdf.zip.

  4. 4

    Turn it on

    Enable the toggle next to the new skill. It now works in every new chat and in projects.

  5. 5

    Test it

    Open a new chat and send the test sentence below. Claude shows when it reads the skill.

Uploaded skills are personal. On Team and Enterprise, owners can provision a skill for the whole organization.

Test sentence for a new chat

Make a PDF out of this HTML

Install or just attach?

Install (recommended)

The skill is ready in every new chat. The tool first reads only the name and description and loads the full instructions when your request fits, so the chat stays lean.

Attach as a file

Dropping SKILL.md into a single chat works in any tool, but only for that one chat. Good for trying it out, not for daily use.

ZIP or SKILL.md?

The ZIP contains the folder html-to-pdf with SKILL.md and all extra files, exactly as Claude, ChatGPT and Manus expect it. The single SKILL.md is for Gemini, Mistral, Perplexity and for projects or GPTs without a Skills area.

Detailed guide with troubleshooting

Related skills

License and use

This skill is published under Creative Commons BY-NC-ND 4.0. The license text applies unchanged. In addition, the rights holder grants an additional permission (CC+): use inside companies and for client work is allowed, adapting for your own use is allowed. Not allowed: selling, bundling, publishing modified versions.