Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.
Install
npx skills add https://github.com/anthropics/skills --skill pdfPDF Processing Advanced Reference
This document contains advanced PDF processing features, detailed examples, and additional libraries not covered in the main skill instructions.
pypdfium2 Library (Apache/BSD License)
Overview
pypdfium2 is a Python binding for PDFium (Chromium's PDF library). It's excellent for fast PDF rendering, image generation, and serves as a PyMuPDF replacement.
Render PDF to Images
Extract Text with pypdfium2
JavaScript Libraries
pdf-lib (MIT License)
pdf-lib is a powerful JavaScript library for creating and modifying PDF documents in any JavaScript environment.
Load and Manipulate Existing PDF
Create Complex PDFs from Scratch
Advanced Merge and Split Operations
pdfjs-dist (Apache License)
PDF.js is Mozilla's JavaScript library for rendering PDFs in the browser.
Basic PDF Loading and Rendering
Extract Text with Coordinates
Extract Annotations and Forms
Advanced Command-Line Operations
poppler-utils Advanced Features
Extract Text with Bounding Box Coordinates
Advanced Image Conversion
Extract Embedded Images
qpdf Advanced Features
Complex Page Manipulation
PDF Optimization and Repair
Advanced Encryption
Advanced Python Techniques
pdfplumber Advanced Features
Extract Text with Precise Coordinates
Advanced Table Extraction with Custom Settings
reportlab Advanced Features
Create Professional Reports with Tables
Complex Workflows
Extract Figures/Images from PDF
Method 1: Using pdfimages (fastest)
Method 2: Using pypdfium2 + Image Processing
Batch PDF Processing with Error Handling
Advanced PDF Cropping
Performance Optimization Tips
1. For Large PDFs
- Use streaming approaches instead of loading entire PDF in memory
- Use
qpdf --split-pagesfor splitting large files - Process pages individually with pypdfium2
2. For Text Extraction
pdftotext -bbox-layoutis fastest for plain text extraction- Use pdfplumber for structured data and tables
- Avoid
pypdf.extract_text()for very large documents
3. For Image Extraction
pdfimagesis much faster than rendering pages- Use low resolution for previews, high resolution for final output
4. For Form Filling
- pdf-lib maintains form structure better than most alternatives
- Pre-validate form fields before processing
5. Memory Management
Troubleshooting Common Issues
Encrypted PDFs
Corrupted PDFs
Text Extraction Issues
License Information
- pypdf: BSD License
- pdfplumber: MIT License
- pypdfium2: Apache/BSD License
- reportlab: BSD License
- poppler-utils: GPL-2 License
- qpdf: Apache License
- pdf-lib: MIT License
- pdfjs-dist: Apache License