pdf-extract

Extract text, metadata, and annotations from PDF files with provenance sidecars.

Updated Apr 18, 2026
One-click install
npx skills add https://github.com/ppavlidis/skillz --skill pdf-extract-ppavlidis
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pdf-extract
Source: https://github.com/ppavlidis/skillz/tree/main/skills/pdf-extract
Command: npx skills add https://github.com/ppavlidis/skillz --skill pdf-extract-ppavlidis

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pymupdf, pypdf, and includes scripts (resource) components.

What problem does it solve? Reading PDFs, pulling out highlights and sticky notes, or retrieving a paper's DOI and title usually requires manual copy-paste or ad-hoc scripts with no record of how the data was produced. This Skill performs reproducible, offline PDF extraction with no LLM calls, and stamps every output with a provenance sidecar recording the input sha256, library version, and extraction timestamp. ## Core Features & Use Cases - Document metadata extraction: Retrieves title, authors, DOI, year, keywords, and page count from XMP metadata, docinfo fields, and first-page heuristics. - Page-tagged text extraction: Dumps body text per page in JSON or plain text, with optional page-range filtering like "3-8" or "1,3,5-7". - Annotation extraction: Captures highlights, underlines, strikethroughs, sticky notes, and more, resolving the highlighted text from the PDF text stream. - Use Case: A researcher has a folder of annotated journal PDFs and needs every highlight plus each paper's DOI for a literature review. Running extract.py all paper.pdf produces a single JSON bundle with text, metadata, and annotations, plus a verifiable provenance record. ## Quick Start Ask the AI to extract all annotations and metadata from your PDF file, for example: "Extract the highlights and DOI from paper.pdf using the pdf-extract skill."

Frequently Asked Questions about pdf-extract

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I extract highlights and annotations from a PDF in Python?

Run `python scripts/extract.py annotations paper.pdf` with pymupdf installed. It captures Highlight, Underline, StrikeOut, Squiggly, Text, FreeText, and other annotation types, resolving the marked text from the page's word stream into a JSON file.

How to get the DOI and title from a PDF paper?

Run `python scripts/extract.py metadata paper.pdf`. The DOI is looked up in XMP metadata first, then the docinfo subject, then a regex search of the first page. Title falls back to the largest-font text block on page 1 if docinfo is empty.

pymupdf vs pypdf for PDF text extraction?

pymupdf is the primary library here and is required for annotation extraction; pypdf is an optional fallback that handles text and metadata only. pymupdf is AGPL-licensed, while pypdf is MIT for fully permissive operation.

Why is highlighted_text null when extracting PDF annotations?

A null highlighted_text means the PDF has no text layer, which happens with scanned image-only documents. Run an OCR tool such as ocrmypdf first to add a text layer, then re-run the extraction.

Can I extract text from only specific pages of a PDF?

Yes, pass the --pages flag to the text operation, accepting formats like "3", "2-5", or "1,3,5-7". Use --format text for plain output with page markers or the default JSON for per-page structured output.

What are the limitations of automated PDF metadata extraction?

Encrypted PDFs raise an error and must be decrypted first with qpdf. The year heuristic grabs the first four-digit number in 1900-2099 on page 1, which can catch grant numbers, and DOIs split across line breaks are not reassembled.