Local PDF Reader
Overview
This skill handles local PDF-reading tasks from an absolute file path. It supports three common cases:
- Read the full text of a PDF
- Read one page or a page range
- Extract highlighted text or titles from PDF highlight annotations
Use the bundled script first when the environment lacks pdftotext, Python PDF packages, or OCR tools.
Workflow
- Confirm the file exists and note the page count:
file "/abs/path/to/file.pdf"
bash scripts/read_local_pdf.sh pages "/abs/path/to/file.pdf"
- Choose the extraction mode:
- Full document text:
bash scripts/read_local_pdf.sh text "/abs/path/to/file.pdf"
- Specific page:
bash scripts/read_local_pdf.sh text "/abs/path/to/file.pdf" 12
- Page range:
bash scripts/read_local_pdf.sh text "/abs/path/to/file.pdf" 12 15
- Highlighted text:
bash scripts/read_local_pdf.sh highlights "/abs/path/to/file.pdf"
- Post-process for the user's intent:
- If the user asked what is highlighted, report the extracted highlight text grouped by page.
- If the user asked for titles, keep only the title-like lines instead of dumping all text.
- If the user asked for a summary, read the relevant page text first, then summarize.
Heuristics
- Prefer
highlightswhen the user mentions "标黄", "highlight", "annotations", or asks which titles were highlighted. - Prefer
textwhen the user asks to read page content, extract a section, or summarize the PDF. - If highlight extraction returns nothing, say that the PDF may not contain saved highlight annotations. Then fall back to page text extraction.
- The bundled script reads text-based PDFs. For scanned PDFs, you may need OCR; this skill does not bundle OCR.
Output Discipline
- Keep page numbers in the result when multiple pages are involved.
- Do not dump the whole document unless the user asked for it.
- When titles are clearly identifiable, return just the titles first and mention that they were extracted from PDF highlights or page text.
Bundled Script
The script compiles a temporary Objective-C helper against macOS PDFKit and supports:
pagestexthighlights
Run it from the skill directory or reference it by absolute path.