Manipulate PDF files including merge, split, extract, redact, convert, and secure workflows.
npx skills add https://github.com/besoeasy/open-skills --skill pdf-manipulation
Merge, split, extract, redact, and transform PDF files using free command-line tools and libraries. Covers common PDF operations for document automation workflows.
# Ubuntu/Debian
sudo apt-get install pdftk qpdf poppler-utils ghostscript
# macOS (Homebrew)
brew install pdftk-java qpdf poppler ghostscript
# For Node.js: npm i pdf-lib (pure JS, no system deps)
# For Python: pip install PyPDF2 pypdf
# Using pdftk (preserves bookmarks, forms)
pdftk file1.pdf file2.pdf file3.pdf cat output merged.pdf
# Using ghostscript (better compression)
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=merged.pdf file1.pdf file2.pdf file3.pdf
# Using qpdf (preserves structure)
qpdf --empty --pages file1.pdf file2.pdf file3.pdf -- merged.pdf
Node.js (pdf-lib):
const { PDFDocument } = require('pdf-lib');
const fs = require('fs');
async function mergePDFs(files, output) {
const mergedPdf = await PDFDocument.create();
for (const file of files) {
const pdfBytes = fs.readFileSync(file);
const pdf = await PDFDocument.load(pdfBytes);
const pages = await mergedPdf.copyPages(pdf, pdf.getPageIndices());
pages.forEach(page => mergedPdf.addPage(page));
}
const mergedBytes = await mergedPdf.save();
fs.writeFileSync(output, mergedBytes);
}
// mergePDFs(['file1.pdf', 'file2.pdf'], 'merged.pdf');
# Split every page into separate files
pdftk input.pdf burst output page_%02d.pdf
# Extract specific pages (e.g., pages 1-5 and 10)
pdftk input.pdf cat 1-5 10 output subset.pdf
# Extract page ranges with qpdf
qpdf input.pdf --pages . 1-5 -- output.pdf
# Split every N pages (e.g., every 2 pages)
pdftk input.pdf burst
# then manually combine or script it
Node.js (pdf-lib):
const { PDFDocument } = require('pdf-lib');
const fs = require('fs');
async function extractPages(inputPath, pages, outputPath) {
const pdfBytes = fs.readFileSync(inputPath);
const pdfDoc = await PDFDocument.load(pdfBytes);
const newPdf = await PDFDocument.create();
for (const pageNum of pages) {
const [page] = await newPdf.copyPages(pdfDoc, [pageNum - 1]);
newPdf.addPage(page);
}
const newBytes = await newPdf.save();
fs.writeFileSync(outputPath, newBytes);
}
// extractPages('input.pdf', [1, 3, 5], 'output.pdf');
# Extract all text (preserves layout)
pdftotext input.pdf output.txt
# Extract text as raw (no layout)
pdftotext -raw input.pdf output.txt
# Extract specific pages
pdftotext -f 1 -l 5 input.pdf output.txt
# Using qpdf + pdftotext
pdftotext -layout input.pdf -
Node.js (pdf-parse):
const fs = require('fs');
const pdf = require('pdf-parse');
async function extractText(filePath) {
const dataBuffer = fs.readFileSync(filePath);
const data = await pdf(dataBuffer);
return data.text;
}
// extractText('input.pdf').then(console.log);
# Extract all images from PDF
pdfimages -all input.pdf output_prefix
# Output: output_prefix-000.png, output_prefix-001.jpg, etc.
# Extract only JPEGs
pdfimages -j input.pdf output_prefix
# Remove specific pages (e.g., remove pages 2-4)
pdftk input.pdf cat 1 5-end output redacted.pdf
# Keep only specific pages
pdftk input.pdf cat 1-10 20-30 output selected.pdf
# Encrypt PDF with password
pdftk input.pdf output secured.pdf user_pw mypassword
# Remove password
pdftk secured.pdf input_pw mypassword output unlocked.pdf
# Using qpdf (AES-256)
qpdf --encrypt userpass ownerpass 256 -- input.pdf output.pdf
Node.js (pdf-lib):
const { PDFDocument } = require('pdf-lib');
const fs = require('fs');
async function encryptPDF(inputPath, password, outputPath) {
const pdfBytes = fs.readFileSync(inputPath);
const pdfDoc = await PDFDocument.load(pdfBytes);
const encryptedBytes = await pdfDoc.save({
userPassword: password,
ownerPassword: password
});
fs.writeFileSync(outputPath, encryptedBytes);
}
# Rotate all pages 90 degrees clockwise
pdftk input.pdf cat 1-endright output rotated.pdf
# Rotate specific pages
pdftk input.pdf cat 1-5 6right 7-end output rotated.pdf
# Options: right (90°), left (270°), down (180°)
# Using ghostscript (adjust quality)
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook \
-dNOPAUSE -dQUIET -dBATCH -sOutputFile=compressed.pdf input.pdf
# Quality settings:
# /screen - low quality (72 dpi)
# /ebook - medium (150 dpi)
# /printer - high (300 dpi)
# /prepress - highest (300 dpi, preserves color)
# Using qpdf (lossless compression)
qpdf --linearize --object-streams=generate input.pdf compressed.pdf
# Convert each page to PNG (300 DPI)
pdftoppm -png -r 300 input.pdf output_prefix
# Output: output_prefix-1.png, output_prefix-2.png, etc.
# Convert to JPEG
pdftoppm -jpeg -r 150 input.pdf output_prefix
# Using ImageMagick (alternative)
convert -density 300 input.pdf output_%03d.png
# Overlay watermark.pdf on every page
pdftk input.pdf stamp watermark.pdf output watermarked.pdf
# Background watermark (behind content)
pdftk input.pdf background watermark.pdf output watermarked.pdf
# Watermark specific pages only
pdftk input.pdf multistamp watermark.pdf output watermarked.pdf
# Using pdftk
pdftk input.pdf dump_data
# Using qpdf
qpdf --show-object=1 input.pdf
# Using pdfinfo (poppler-utils)
pdfinfo input.pdf
const { PDFDocument } = require('pdf-lib');
const fs = require('fs');
class PDFHelper {
static async merge(files, output) {
const merged = await PDFDocument.create();
for (const file of files) {
const pdf = await PDFDocument.load(fs.readFileSync(file));
const pages = await merged.copyPages(pdf, pdf.getPageIndices());
pages.forEach(p => merged.addPage(p));
}
fs.writeFileSync(output, await merged.save());
}
static async split(input, ranges, output) {
const pdf = await PDFDocument.load(fs.readFileSync(input));
const newPdf = await PDFDocument.create();
const pages = await newPdf.copyPages(pdf, ranges);
pages.forEach(p => newPdf.addPage(p));
fs.writeFileSync(output, await newPdf.save());
}
static async info(input) {
const pdf = await PDFDocument.load(fs.readFileSync(input));
return {
pages: pdf.getPageCount(),
title: pdf.getTitle(),
author: pdf.getAuthor(),
creator: pdf.getCreator()
};
}
}
module.exports = PDFHelper;
You have PDF manipulation skills. When a user requests PDF operations:
1. Detect the operation: merge, split, extract (text/images/pages), redact, compress, encrypt, rotate, watermark, or get info.
2. Use appropriate tools:
- pdftk for merge, split, rotate, encrypt, watermark
- pdftotext/pdfimages for extraction
- ghostscript for compression
- qpdf for repair and advanced operations
3. Always validate input files exist before processing.
4. For scripting, prefer pdf-lib (Node.js) or PyPDF2 (Python) for portability.
5. Return structured output (file paths, metadata, text) in JSON format.
qpdf --check input.pdf)./ebook is a good balance for most cases.# 1. Extract text for parsing
pdftotext invoice.pdf invoice.txt
# 2. Extract first page only (summary)
pdftk invoice.pdf cat 1 output summary.pdf
# 3. Compress for archival
gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -dBATCH -dNOPAUSE -q \
-sOutputFile=invoice_compressed.pdf invoice.pdf
# Merge all PDFs in a directory
pdftk *.pdf cat output combined.pdf
# Split each PDF in directory into individual pages
for f in *.pdf; do
pdftk "$f" burst output "${f%.pdf}_page_%02d.pdf"
done
# Extract text from all PDFs
for f in *.pdf; do
pdftotext "$f" "${f%.pdf}.txt"
done
qpdf --check then qpdf input.pdf --replace-input to repair.qpdf --decrypt --password=PASS input.pdf output.pdf.fonts-liberation or msttcorefonts packages.Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks
Comprehensive PDF manipulation toolkit for extracting text and tables, creating new PDFs, merging/splitting documents, and handling forms. When Claude needs to fill in a PDF form or programmatically process, generate, or analyze PDF documents at scale.
Presentation creation, editing, and analysis. When Claude needs to work with presentations (.pptx files) for: (1) Creating new presentations, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other presentation tasks
Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.
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.
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.
Use this skill any time a .pptx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates, layouts, speaker notes, or comments. Trigger whenever the user mentions \"deck,\" \"slides,\" \"presentation,\" or references a .pptx filename, regardless of what they plan to do with the content afterward. If a .pptx file needs to be opened, created, or touched, use this skill.
Create and edit Obsidian Flavored Markdown with wikilinks, embeds, callouts, properties, and other Obsidian-specific syntax. Use when working with .md files in Obsidian, or when the user mentions wikilinks, callouts, frontmatter, tags, embeds, or Obsidian notes.
Take besoeasy/pdf-manipulation from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.
The instructions reference pip, npm, brew, apt.
Without those the skill loads but fails at the first command.