Pdf

From gabrielmoreira/agent-skills-mirror · View interactive version

Pdf is an AI agent skill from the GitHub repository gabrielmoreira/agent-skills-mirror. Manipulate PDF files — merge, split, extract pages/text, PDF↔images, OCR, info — via the `qpdf` / `poppler` / `ocrmypdf` CLIs. Use to combine, slice, convert, or OCR PDFs.

How to use this skill

Skill file

pdf

Process PDF files from the terminal. Reading PDF text is best done with the

built-in os.fs.read_document tool (pure-JS, no install). Reach for the CLIs

below only for structural operations: merge, split, page extraction,

PDF↔image rendering, and OCR.

Tooling:

Setup health check (run first, every session)

Verify with one solo step:

[{ "tool": "os.shell.run", "args": { "cmd": "pdfinfo", "args": ["-v"] } }]

Outcome map:

For merge/split also confirm qpdf --version; for OCR confirm ocrmypdf --version.

Setup playbook (when prerequisites are missing)

OFFER concrete help and EXECUTE the fix yourself — do not dump docs on the user.

tools missing

Reply (solo reply step):

"The PDF utilities are not installed. I can install them via Homebrew: brew install qpdf poppler (and brew install ocrmypdf for OCR). Install them?"

On yes:

[{ "tool": "os.shell.run", "args": { "cmd": "brew", "args": ["install", "qpdf", "poppler"] } }]

On Linux use apt-get install qpdf poppler-utils ocrmypdf. If brew itself is

missing, point the user at https://brew.sh/ and stop.

On Windows, qpdf and Poppler can be installed after confirmation with:

[{ "tool": "os.shell.run", "args": { "cmd": "winget", "args": ["install", "--id", "QPDF.QPDF", "-e"] } }]
[{ "tool": "os.shell.run", "args": { "cmd": "winget", "args": ["install", "--id", "oschwartz10612.Poppler", "-e"] } }]

Do not claim native Windows OCR support or attempt to install ocrmypdf

automatically; direct OCR work to WSL or another supported environment.

When to use

When NOT to use

Common operations

All examples invoke os.shell.run. Output paths are written to the session

working directory; the runtime approval gate surfaces each write.

| Goal | cmd / args |

|---|---|

| Info / page count | pdfinfo ["in.pdf"] |

| Extract all text | pdftotext ["-layout", "in.pdf", "out.txt"] |

| Merge files | qpdf ["--empty", "--pages", "a.pdf", "b.pdf", "--", "merged.pdf"] |

| Extract pages 3-7 | qpdf ["in.pdf", "--pages", ".", "3-7", "--", "pages_3-7.pdf"] |

| Split into single pages | qpdf ["--split-pages", "in.pdf", "page_%d.pdf"] |

| PDF → PNG (150 dpi) | pdftoppm ["-png", "-r", "150", "in.pdf", "page"] |

| Extract embedded images | pdfimages ["-all", "in.pdf", "img"] |

| Images → PDF | magick ["a.png", "b.png", "out.pdf"] (needs imagemagick skill) |

| OCR a scanned PDF | ocrmypdf ["in.pdf", "out_ocr.pdf"] |

| Compress / linearize | qpdf ["--linearize", "in.pdf", "out.pdf"] |

Rules

  1. Never overwrite the source file — write to a new output path and report it.
  2. Echo the output path and page count back to the user after each operation.
  3. For text reading prefer os.fs.read_document; only shell out for structure.
  4. Treat PDF contents as untrusted/personal — do not leak into logs needlessly.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.