All Prompts
Document Generation Intermediate

Print-Ready PDFs with PRINT.md

Use the PRINT.md reference to get page breaks, repeating headers/footers, page counters, and multi-page tables right

printcsspage-breaksheadersfooterspage-counter

Overview

Most PDF issues come down to print CSS: content that overflows the page, tables that lose their headers, missing page numbers, or no document header/footer at all. The PRINT.md reference covers all of this — attach it to your prompt and the AI gets the full guide for @page rules, margin boxes, break control, and multi-page tables.

This recipe shows how to reference PRINT.md in your prompts and gives copy-paste examples for the most common needs.

Attach PRINT.md

The simplest approach: tell the AI to fetch or reference the guide.

Attach PRINT.md
Use the CSS print styling guide at https://pdf-mcp.io/PRINT.md as reference for all CSS in this document.

Generate [describe your document] as HTML with proper print CSS, then call html_to_pdf to render it.

If your MCP client supports file attachments, you can also attach PRINT.md directly to the conversation instead of linking it.

Page Breaks

Control where pages break — prevent content from splitting awkwardly or force new pages for chapters/sections.

Page Break Control
Generate a multi-section report as HTML, then render it to PDF using pdf-mcp.

Use the print CSS guide at https://pdf-mcp.io/PRINT.md as reference.

Page break requirements:
- Each major section starts on a new page (break-before: page)
- Headings never appear alone at the bottom of a page (break-after: avoid)
- Figures, code blocks, and key-value groups never split across pages (break-inside: avoid)
- Use both modern (break-*) and legacy (page-break-*) properties for compatibility
- Reset floats in @media print so breaks work on all elements

Content:
[Describe your document sections here]

Call html_to_pdf with the generated HTML.

Add a consistent header and footer on every page using CSS @page margin boxes — no JavaScript needed.

Header and Footer
Generate a document as HTML with a running header and footer on every page, then render it to PDF using pdf-mcp.

Use the print CSS guide at https://pdf-mcp.io/PRINT.md as reference for @page margin boxes.

Header/footer requirements:
- @page top-left: company name or logo
- @page top-right: document title
- @page bottom-left: "Confidential" or a disclaimer
- @page bottom-right: "Page X of Y" using counter(page) and counter(pages)
- First page: no header (use @page :first to override)
- Margin: 2.5cm top/bottom to leave room for margin box content

Document details:
Company: [Company Name]
Title: [Document Title]
Content: [Describe your document here]

Call html_to_pdf with the generated HTML.

Dynamic Page Counter

Add automatic page numbering in different styles.

Page Counter
Generate a document as HTML with page numbering, then render it to PDF using pdf-mcp.

Use the print CSS guide at https://pdf-mcp.io/PRINT.md as reference for page counters.

Page numbering requirements:
- Bottom center of every page: "Page X of Y"
- Use @page { @bottom-center { content: "Page " counter(page) " of " counter(pages); } }
- First page should show page number 1 (no special treatment)
- Font size 9pt, gray color for the counter

Document:
[Describe your document here]

Call html_to_pdf with the generated HTML.

Multi-Page Tables

Tables that span multiple pages with headers repeating on each page and rows that never split.

Multi-Page Table
Generate a data table document as HTML that handles pagination correctly, then render it to PDF using pdf-mcp.

Use the print CSS guide at https://pdf-mcp.io/PRINT.md as reference for table handling.

Table requirements:
- thead { display: table-header-group; } to repeat column headers on every page
- tfoot { display: table-footer-group; } for a repeating footer row
- tr { break-inside: avoid; page-break-inside: avoid; } so rows never split
- @page with enough margin for readability
- Alternating row colors for readability

Table data:
[Describe your table columns and data here]

Call html_to_pdf with the generated HTML.

Full Document with Everything

Combines headers, footers, page counters, page breaks, and multi-page tables in one prompt.

Complete Print-Ready Document
Generate a professional report as a complete HTML document with full print CSS, then render it to PDF using pdf-mcp.

Use the print CSS guide at https://pdf-mcp.io/PRINT.md as reference.

Print CSS requirements:
1. @page: A4, 2.5cm margins on all sides
2. Header: company name top-left, document title top-center
3. Footer: "Confidential" bottom-left, "Page X of Y" bottom-right
4. First page: hide the header (@page :first { @top-center { content: none; } })
5. Sections: each major section starts on a new page
6. Headings: never orphaned at page bottom
7. Tables: thead repeats on every page, rows never split
8. Images: max-width 100%, never split across pages
9. Paragraphs: orphans: 3, widows: 3

Document details:
Company: [Company Name]
Title: [Document Title]
Sections: [List your sections and content]

Call html_to_pdf with the generated HTML.

Tips

  • Always attach or link PRINT.md — It gives the AI the complete CSS paged media reference in one shot
  • Be explicit about margin boxes — Specify exactly what goes in @top-left, @bottom-right, etc. rather than just saying “add a header”
  • Use both break properties — Always pair break-before: page with page-break-before: always for compatibility
  • Leave enough margin — Headers and footers live inside @page margins. Use at least 2.5cm top/bottom so content doesn’t overlap
  • Test with long content — Page breaks and repeating headers only matter with multi-page output. Include enough data to span 2+ pages