Back to list
vasilyu1983

document-pdf

by vasilyu1983

25🍴 6📅 Jan 23, 2026

SKILL.md


name: document-pdf description: Extract text and tables from PDFs, create formatted PDFs, merge/split documents, handle forms and annotations. Supports pdf-lib, pdfkit, PyPDF2, pdfplumber, and ReportLab for comprehensive PDF workflows in Node.js and Python.

Document PDF Skill — Quick Reference

This skill enables PDF creation, extraction, manipulation, and analysis. Claude should apply these patterns when users need to generate invoices, reports, extract data from PDFs, merge documents, or work with PDF forms.

Modern Best Practices (Jan 2026):

  • PDF is a release artifact, not the editable source of truth.
  • Validate export fidelity (fonts, images, links) and accessibility baseline where applicable.
  • Accessibility (WCAG 2.1 AA by April 2026): tags, reading order, alt text. ADA compliance deadline.
  • EU Distribution: EAA (June 2025) requires EN 301 549 compliance for PDFs distributed in EU.
  • Treat PDFs as sensitive: scrub metadata, ensure real redaction, and control distribution.

Quick Reference

TaskTool/LibraryLanguageWhen to Use
Create PDFpdfkitNode.jsReports, invoices, certificates
Create PDFReportLabPythonComplex layouts, tables
Create PDFFPDF2PythonSimple PDFs with Unicode support
Create PDFBorbPythonInteractive elements, pure Python
Edit PDFpdf-libNode.jsModify existing PDFs, add pages
Extract textpdfplumberPythonOCR-free text extraction
Extract tablesCamelotPythonTables with borders (Lattice mode)
Extract tablesCamelot/TabulaPythonTables without borders (Stream mode)
Parse PDFpypdfPythonMerge, split, rotate pages
Fill formspdf-libNode.jsForm automation
HTML to PDFPuppeteer/PlaywrightNode.jsHigh-fidelity web page rendering
HTML to PDFWeasyPrintPythonCSS3-based, no browser needed

When to Use This Skill

Claude should invoke this skill when a user requests:

  • Generate PDFs from data (invoices, reports, certificates)
  • Extract text or tables from existing PDFs
  • Merge multiple PDFs into one document
  • Split PDFs into separate files
  • Fill PDF forms programmatically
  • Add watermarks, headers, footers
  • Convert HTML/web pages to PDF

Core Operations

Create PDF (Node.js - pdfkit)

import PDFDocument from 'pdfkit';
import fs from 'fs';

const doc = new PDFDocument();
doc.pipe(fs.createWriteStream('output.pdf'));

// Title
doc.fontSize(25).text('Invoice', { align: 'center' });
doc.moveDown();

// Content
doc.fontSize(12).text('Bill To: Acme Corp');
doc.text('Date: 2025-01-15');
doc.moveDown();

// Table-like structure
doc.text('Item                  Qty    Price');
doc.text('Widget A               10    $100');
doc.text('Widget B                5    $250');
doc.moveDown();
doc.text('Total: $350', { align: 'right' });

// Image
doc.image('logo.png', { width: 100 });

doc.end();

Create PDF (Python - ReportLab)

from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from reportlab.lib.units import inch
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle
from reportlab.lib import colors

# Simple canvas approach
c = canvas.Canvas('output.pdf', pagesize=letter)
c.setFont('Helvetica-Bold', 24)
c.drawString(100, 750, 'Invoice')
c.setFont('Helvetica', 12)
c.drawString(100, 700, 'Bill To: Acme Corp')
c.save()

# Table with platypus
doc = SimpleDocTemplate('table.pdf', pagesize=letter)
data = [
    ['Item', 'Qty', 'Price'],
    ['Widget A', '10', '$100'],
    ['Widget B', '5', '$250'],
]
table = Table(data)
table.setStyle(TableStyle([
    ('BACKGROUND', (0, 0), (-1, 0), colors.grey),
    ('GRID', (0, 0), (-1, -1), 1, colors.black),
]))
doc.build([table])

Extract Text (Python - pdfplumber)

import pdfplumber

with pdfplumber.open('document.pdf') as pdf:
    for page in pdf.pages:
        text = page.extract_text()
        print(text)

        # Extract tables
        tables = page.extract_tables()
        for table in tables:
            for row in table:
                print(row)

Modify PDF (Node.js - pdf-lib)

import { PDFDocument, rgb, StandardFonts } from 'pdf-lib';
import fs from 'fs';

// Load existing PDF
const existingPdfBytes = fs.readFileSync('input.pdf');
const pdfDoc = await PDFDocument.load(existingPdfBytes);

// Add watermark to all pages
const helveticaFont = await pdfDoc.embedFont(StandardFonts.Helvetica);
const pages = pdfDoc.getPages();

for (const page of pages) {
  const { width, height } = page.getSize();
  page.drawText('CONFIDENTIAL', {
    x: width / 2 - 50,
    y: height / 2,
    size: 50,
    font: helveticaFont,
    color: rgb(0.9, 0.9, 0.9),
    rotate: { angle: 45, type: 'degrees' },
  });
}

// Save
const pdfBytes = await pdfDoc.save();
fs.writeFileSync('output.pdf', pdfBytes);

Merge PDFs (Python - pypdf)

from pypdf import PdfMerger

merger = PdfMerger()
merger.append('doc1.pdf')
merger.append('doc2.pdf')
merger.append('doc3.pdf', pages=(0, 5))  # First 5 pages only
merger.write('merged.pdf')
merger.close()

HTML to PDF (Node.js - Puppeteer)

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
const page = await browser.newPage();

// From URL
await page.goto('https://example.com');
await page.pdf({ path: 'page.pdf', format: 'A4' });

// From HTML string
await page.setContent('<h1>Hello World</h1><p>Generated PDF</p>');
await page.pdf({
  path: 'generated.pdf',
  format: 'A4',
  printBackground: true,
  margin: { top: '1in', bottom: '1in' }
});

await browser.close();

PDF Structure Patterns

Invoice Template

INVOICE STRUCTURE
├── Header (logo, company info, invoice #)
├── Bill To / Ship To blocks
├── Line items table
│   ├── Description | Qty | Unit Price | Total
│   └── Subtotal, Tax, Total
├── Payment terms
└── Footer (contact, thank you)

Report Template

REPORT PDF STRUCTURE
├── Cover page (title, author, date)
├── Table of contents
├── Body sections with page numbers
├── Charts/images with captions
├── Appendices
└── Running header/footer

Decision Tree

PDF Task: [What do you need?]
    ├─ Create new PDF?
    │   ├─ Simple text/tables → pdfkit (Node) or ReportLab (Python)
    │   ├─ Complex layouts → ReportLab with Platypus
    │   └─ From HTML → Puppeteer or wkhtmltopdf
    │
    ├─ Extract from PDF?
    │   ├─ Text only → pdfplumber (Python)
    │   ├─ Tables → pdfplumber or camelot (Python)
    │   └─ Images → PyMuPDF/fitz (Python)
    │
    ├─ Modify existing PDF?
    │   ├─ Add text/images → pdf-lib (Node)
    │   ├─ Merge/split → pypdf or pdf-lib
    │   └─ Fill forms → pdf-lib
    │
    └─ Batch processing?
        └─ pypdf + pdfplumber pipeline

Do / Avoid (Dec 2025)

Do

  • Keep a versioned source document (doc/slide/design file) alongside the PDF.
  • Verify links and reading order for long documents.
  • Use real redaction and test by copy/paste.

Avoid

  • Editing PDFs as the primary workflow when a source doc exists.
  • Shipping PDFs with broken links or illegible charts.
  • Including customer PII or secrets in PDFs without explicit approval.

What Good Looks Like

  • Fidelity: export is reproducible from a versioned source file (doc/slide/design) and looks identical across viewers.
  • Accessibility: tags/reading order are correct; links work; scanned docs are OCRed when appropriate.
  • Release hygiene: file naming includes version/date; metadata is clean; no “PDF as source of truth”.
  • Security: redaction is verified (copy/paste test) and sensitive data is minimized.
  • QA: release checklist completed using assets/pdf-release-checklist.md.

Optional: AI / Automation

Use only when explicitly requested and policy-compliant.

  • Generate a release checklist run; humans verify the final PDF manually.

Resources

Templates

Related Skills

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon