Merging, Splitting, and Extracting Tables from PDFs with Claude Code — the pdf Skill
機械翻訳 / Machine-translated
Original article: Merging, Splitting, and Extracting Tables from PDFs with Claude Code — the pdf Skill (cccskills)
Skill page: pdf
Key takeaways from this article
With the pdf skill installed, you can ask Claude Code in plain language to merge PDFs, extract specific pages, or convert tables to Excel.
Text and image extraction, rotation, PDF creation, form filling, OCR for scanned documents, and password protection are also supported.
This article covers example prompts, installation steps, and things to verify before getting started.
With the pdf skill installed, you can request PDF processing using natural language.
For example, you might send something like:
Extract all the tables in sales_report.pdf and consolidate them into a single Excel file.
The agent uses a Python library called pdfplumber to read the tables on each page in sequence.
It treats the first row of each table as column headers and stacks the tables from all pages into one.
The result is saved as an Excel file with a name like extracted_tables.xlsx.
This skill is designed to activate whenever a .pdf file is mentioned or when you ask to create a PDF.
You don't need to name the skill every time — just bring up PDFs and the procedure is invoked automatically.
The work of copying and pasting tables one by one is replaced by simply reviewing the finished Excel file.
The pdf skill bundles together procedures for reading, processing, and creating PDFs.
Methods for working with PDFs using Python libraries and command-line tools are organized by task.
From the user's perspective, they fall into four categories.
The body text of a PDF can be extracted as plain text.
Options include extracting while preserving layout and limiting the range to specific pages, such as pages 1–5.
Tables can be read page by page and compiled into an Excel file.
Images embedded in a PDF are exported as sequentially numbered JPEG files.
Reading metadata such as title and author is also supported.
Multiple PDFs can be merged into one in a specified order.
Splitting into individual page files and extracting a range such as "pages 6–10 only" are also supported.
Rotating pages by 90 degrees to fix orientation is included as well.
A watermark PDF can be overlaid on all pages.
New PDFs can be created with text content laid out inside.
Multi-page report formats with titles, body text, and page breaks are supported.
PDF form filling follows the steps in the included FORMS.md file.
Scripts for extracting field information and writing values into fields are bundled with the skill.
For PDFs created by scanning paper documents, each page is converted to an image before being processed by OCR (optical character recognition).
The recognized text is returned in order with page numbers.
Adding a password to a PDF and removing protection from a password-protected PDF (when the password is known) are also supported.
The pdf skill can be installed with a single command or by sending a request to the agent.
To install via command, run the following:
npx skills add https://github.com/anthropics/skills --skill pdf
This command lets you choose which agent to install into, such as Claude Code or Codex.
To have the agent handle the installation, send the following message as-is:
次の Agent Skill をインストールしてください。
https://github.com/anthropics/skills/tree/main/skills/pdf
まず SKILL.md と付属ファイルの中身を確認し、不審な処理(外部への送信、認証情報の読み取りなど)がないことを確かめてから、Claude Code なら ~/.claude/skills/pdf/、Codex なら ~/.agents/skills/pdf/ に配置してください。
The installation locations are shown in the table below.
Use the user-level location to make the skill available across all projects, or the project-level location to restrict it to a specific project.
| Agent | User-level | Project-level |
|---|---|---|
| Claude Code | ~/.claude/skills/ | .claude/skills/ |
| Codex | ~/.agents/skills/ | .agents/skills/ |
The skill is distributed from anthropics/skills on GitHub.
Before installing, take a look at the SKILL.md and accompanying files on that page.
In your request, simply state the target filename and the result you want.
Here are three commonly used examples.
Merge the April, May, and June report PDFs into one file in that order.
The first page is landscape, so please fix its orientation too.
The three files will be arranged in the specified order and saved as a single PDF.
The first page will be rotated 90 degrees to match the orientation of the other pages.
The output is written to a new file with a name like merged.pdf.
Extract only pages 6–10 from contract.pdf and save them as a separate PDF.
Only the specified page range is written out to a new PDF.
If you want to split all pages into individual files, you can make the same kind of request.
Read the text in scanned_minutes.pdf and show it to me as text.
Since each page is converted to an image before OCR is applied, the output comes back divided by page with labels like "Page 1" and "Page 2."
Compare the results against the original images to verify accuracy.
Before using the pdf skill, check the required tools and how source files are handled.
The libraries and tools used vary depending on the task.
The main combinations are shown in the table below.
| Task | Tools used |
|---|---|
| Merging, splitting, rotating, passwords | pypdf, qpdf |
| Text and table extraction | pdfplumber, pdftotext (poppler-utils) |
| Exporting tables to Excel | pdfplumber, pandas |
| Creating new PDFs | reportlab |
| OCR for scanned PDFs | pytesseract, pdf2image |
| Image extraction | pdfimages (poppler-utils) |
pdftk is used only when it is already present in the environment.
If anything is missing, have the agent explain what needs to be installed before proceeding.
This makes it easier to understand what is being added to your environment.
The processing examples in SKILL.md write results to a new file with a different name.
Even so, it is safer to make a copy of important documents before making a request.
Specifying the output filename in your request will make it easy to identify which file is the processed version.
The OCR examples do not specify a recognition language.
When processing scanned documents in Japanese, always verify the results.
When creating PDFs with reportlab, subscript and superscript Unicode characters will appear as black squares and must be written using dedicated tags.
The license uses custom terms; the full text is in LICENSE.txt.
Before installing, read SKILL.md and the accompanying scripts to confirm there are no suspicious operations such as sending data externally.
If you also work with Word documents alongside PDFs, the docx skill from the same repository will be useful.
It supports creating and editing Word documents and templates, as well as extracting content.
Table and image placement, tracked changes, and comments are also handled.
Yes, it will.
The pdf skill is designed to activate whenever a .pdf file is mentioned or when you ask to create a PDF.
Yes.
When running the install command, select Codex as the target, or place the skill at ~/.agents/skills/pdf/.
Yes.
Form filling works by following the steps in the included FORMS.md file.
Scripts for extracting field information and writing values into fields are bundled as well.
With the pdf skill installed, you can request PDF merging, splitting, rotation, table-to-Excel conversion, and OCR for scanned documents all through natural language.
New PDF creation, form filling, and password protection are handled by the same skill.
Before using it, verify the required libraries and review the contents of the included files.
Installation instructions and descriptions are compiled on the cccskills page.
This article is a repost of the cccskills piece "Merging, Splitting, and Extracting Tables from PDFs with Claude Code — the pdf Skill."
Full skill details and installation instructions can be found on the cccskills pdf page.