mcpField
P
pdf-best-practices

pdf-best-practices

github.com/pdfnoodleDocuments2150 installsUpdated 36w ago
Repository

About pdf-best-practices

A reference skill for creating HTML that renders reliably as PDF documents, aimed at developers and document authors. It organizes guidance on page layout, tables, images, and document-specific formats around a Puppeteer-based pipeline.

Key features

  1. 01HTML document structure guidance
  2. 02Page-break and pagination rules
  3. 03PDF table and image formatting
  4. 04Headers, footers, and page numbers
  5. 05Document-type-specific guidelines

Use cases

  1. 01Create reports or invoices as PDFs
  2. 02Prevent table rows from splitting awkwardly
  3. 03Place images with captions across pages
  4. 04Check HTML before PDF generation

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/pdfnoodle/pdf-best-practices --skill pdf-best-practices

After installing, type/pdf-best-practicesin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

LICENSE
package.json
README.md
resources/
document-setup.md
colors.md
document-types.md
page-breaks.md
headers-footers.md
images.md
content-density.md
tables.md

Details

From the project README

PDF Best Practices Skill

Comprehensive guidelines for creating HTML that renders perfectly as PDF documents.

┌─────────────────────────────────────────────────────────────────────────────┐
│                         HTML to PDF Pipeline                                 │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                              │
│   ┌──────────┐    ┌──────────────┐    ┌─────────────┐    ┌──────────────┐  │
│   │  HTML    │───▶│  PDF Engine  │───▶│  Pagination │───▶│  Final PDF   │  │
│   │ Content  │    │  (Puppeteer) │    │  & Layout   │    │  Document    │  │
│   └──────────┘    └──────────────┘    └─────────────┘    └──────────────┘  │
│        │                                     │                              │
│        ▼                                     ▼                              │
│   ┌──────────┐                        ┌─────────────┐                       │
│   │  CSS     │                        │ Page Breaks │                       │
│   │  Styles  │                        │  & Margins  │                       │
│   └──────────┘                        └─────────────┘                       │
│                                                                              │
└─────────────────────────────────────────────────────────────────────────────┘

Quick Reference

I want to...Read this
Set up document structure correctlyDocument Setup
Control page breaksPage Breaks
Format tables for PDFTables
Handle images properlyImages
Optimize content densityContent Density
Set up colors and backgroundsColors & Backgrounds
Add headers, footers, page numbersHeaders & Footers
Create specific document typesDocument Types

Start Here

Building a new PDF document?
  1. Start with Document Setup for the HTML structure
  2. Review Page Breaks to prevent awkward splits
  3. Check Content Density to avoid sparse pages
Working with data tables?
  1. Read Tables for formatting and header repetition
  2. Apply Page Breaks to prevent row splitting
Document has images?
  1. Follow Images for sizing and positioning
  2. Use Page Breaks to keep images with captions
Creating a specific document type?
  1. Check Document Types for type-specific guidelines
  2. Available types: Invoice, Report, Certificate, Letter, Table-heavy, Image-heavy

Default Configuration

When generating PDFs, use these recommended parameters:

{
  "format": "A4",
  "margin": {
    "top": "40px",
    "right": "40px",
    "bottom": "40px",
    "left": "40px"
  },
  "printBackground": true
}

Quick Checklist

Before generating any PDF:

  • Complete HTML structure with DOCTYPE, html, head, body
  • CSS includes @page rule with A4 size
  • Body has -webkit-print-color-adjust: exact
  • All images have explicit width/height
  • Tables use thead/tbody structure
  • page-break-inside: avoid on logical content blocks
  • Headings have page-break-after: avoid
  • No excessive whitespace or sparse pages
  • Font sizes are 9pt or larger
  • Colors have sufficient contrast
  • pdfParams includes format, margins, and printBackground: true

Comments

Markdown supported