PDF
Summary
Use this skill for PDF reading, extraction, generation, page operations, forms,
rendering, and optional OCR. Match the tool to the operation instead of treating
PDF as a simple editable text format.
Common neutral backends include pypdf for page and metadata operations,
pdfplumber for text and table inspection, ReportLab or pdf-lib for
generation, HTML/CSS plus a local browser for typography-heavy documents,
Poppler for rendering, and qpdf for structural checks. OCR is a separate,
explicitly selected path such as local Tesseract.
When To Use
- Extracting text, tables, metadata, links, bookmarks, or form information
- Splitting, merging, rotating, cropping, stamping, or encrypting documents
- Generating a PDF from structured content
- Rendering pages for visual review
- Running OCR on operator-approved scanned pages
- Comparing page-level content before and after a transformation
Safety Boundaries
- Preserve the original and write transformed output to a new path.
- Treat JavaScript, actions, attachments, forms, links, signatures, and embedded
files as untrusted.
- Never execute document JavaScript, launch actions, embedded programs, or
external links.
- Do not remove passwords, permissions, signatures, or protection as a way to
bypass access controls.
- External OCR or conversion requires explicit approval before upload.
- Warn that any content change can invalidate a digital signature.
If a parser reports corruption, suspicious object expansion, extreme page
dimensions, excessive object counts, or unsupported encryption, stop the
operation and report the limitation.
Backend Selection
- Use pypdf for page assembly, rotation, cropping, metadata, common forms,
and supported encryption operations.
- Use pdfplumber for positioned text and rule-based table extraction.
- Prefer HTML/CSS plus a local browser or WeasyPrint for reports, proposals,
manuals, and other prose-heavy documents where typography and page design
matter.
- Use ReportLab or pdf-lib for precise drawing, overlays, labels, forms,
and documents whose layout is naturally coordinate-driven.
- Use Poppler tools for local text extraction or rendering when installed.
- Use qpdf for structural validation and supported transformations.
- Use Tesseract only for explicitly requested local OCR and retain the
original page images.
Do not describe text replacement as general PDF editing. Existing visual
content usually requires reconstruction, redaction, annotation, or a source
document change rather than in-place prose editing.
Workflow
- Confirm the requested pages, operation, output path, preservation needs,
forms or bookmarks requirements, and whether OCR is allowed.
- Identify the file type and inspect encryption, signatures, actions,
attachments, links, page boxes, fonts, and page count.
- Decide whether the task is extraction, page transformation, annotation,
redaction, generation, or reconstruction.
- For generation, establish the document type, audience, visual tone, page
size, language coverage, font files, hierarchy, color tokens, and recurring
components before writing rendering code. Read
references/generation.md for the required
typography and layout workflow. The reusable
assets/chinese-report.css is a neutral starting
point for polished Chinese or mixed Chinese/Latin reports, not a substitute
for matching the operator's requested brand or style.
- Select the narrowest local backend that supports the operation.
- Produce a new output without activating links or embedded content.
- Reopen the result and check page count, dimensions, metadata, bookmarks,
forms, attachments, encryption state, and expected text.
- Render every changed or generated page to images. Inspect the actual pages,
not only the source HTML or drawing commands, and revise visible defects
before delivery.
- For extraction or OCR, sample the output against rendered pages and record
ambiguous tables, reading order, missing glyphs, and low-confidence text.
Quality Rules
- Never rely on Helvetica, Times, or another Latin-only base font for Chinese,
Japanese, or Korean text. Discover an appropriate local font, verify glyph
coverage, and ensure fonts are embedded or otherwise reliably available in
the produced PDF.
- Use a deliberate type scale, spacing rhythm, margins, line length, and color
palette. A technically valid PDF with backend-default styling is not a
finished generated document.
- For prose-heavy documents, prefer semantic flow layout over manually placing
every line. Prevent headings, tables, figures, and callouts from splitting in
visually confusing ways.
- Check rendered pages for missing-glyph boxes, substituted fonts, clipping,
overlap, isolated headings, sparse spill pages, inconsistent spacing, weak
contrast, and unreadably dense tables.
- Preserve intended page order, orientation, crop boxes, and dimensions.
- Distinguish visual redaction from secure content removal; verify that redacted
text and related objects are not extractable.
- Do not infer table structure without checking coordinates and rendered pages.
- Retain source page references in extracted content when useful.
- Label OCR-derived text and do not silently replace uncertain characters.
- Verify links, bookmarks, forms, and signatures if the requested operation can
affect them.
Delivery
Report the output path, page range and operation, tools used, whether OCR or any
network service was used, structural and visual checks, signature or form
impact, font family and embedding status for generated documents, and extraction
or OCR limitations. State explicitly when active content was present but not
executed.
1---2name: pdf3description: Inspect, extract, assemble, generate, render, OCR, and validate PDF files with local tools while treating active content and external services as explicit security boundaries.4---56# PDF78## Summary910Use this skill for PDF reading, extraction, generation, page operations, forms,11rendering, and optional OCR. Match the tool to the operation instead of treating12PDF as a simple editable text format.1314Common neutral backends include `pypdf` for page and metadata operations,15`pdfplumber` for text and table inspection, ReportLab or `pdf-lib` for16generation, HTML/CSS plus a local browser for typography-heavy documents,17Poppler for rendering, and qpdf for structural checks. OCR is a separate,18explicitly selected path such as local Tesseract.1920## When To Use2122- Extracting text, tables, metadata, links, bookmarks, or form information23- Splitting, merging, rotating, cropping, stamping, or encrypting documents24- Generating a PDF from structured content25- Rendering pages for visual review26- Running OCR on operator-approved scanned pages27- Comparing page-level content before and after a transformation2829## Safety Boundaries3031- Preserve the original and write transformed output to a new path.32- Treat JavaScript, actions, attachments, forms, links, signatures, and embedded33 files as untrusted.34- Never execute document JavaScript, launch actions, embedded programs, or35 external links.36- Do not remove passwords, permissions, signatures, or protection as a way to37 bypass access controls.38- External OCR or conversion requires explicit approval before upload.39- Warn that any content change can invalidate a digital signature.4041If a parser reports corruption, suspicious object expansion, extreme page42dimensions, excessive object counts, or unsupported encryption, stop the43operation and report the limitation.4445## Backend Selection4647- Use **pypdf** for page assembly, rotation, cropping, metadata, common forms,48 and supported encryption operations.49- Use **pdfplumber** for positioned text and rule-based table extraction.50- Prefer **HTML/CSS plus a local browser or WeasyPrint** for reports, proposals,51 manuals, and other prose-heavy documents where typography and page design52 matter.53- Use **ReportLab** or **pdf-lib** for precise drawing, overlays, labels, forms,54 and documents whose layout is naturally coordinate-driven.55- Use **Poppler** tools for local text extraction or rendering when installed.56- Use **qpdf** for structural validation and supported transformations.57- Use **Tesseract** only for explicitly requested local OCR and retain the58 original page images.5960Do not describe text replacement as general PDF editing. Existing visual61content usually requires reconstruction, redaction, annotation, or a source62document change rather than in-place prose editing.6364## Workflow65661. Confirm the requested pages, operation, output path, preservation needs,67 forms or bookmarks requirements, and whether OCR is allowed.682. Identify the file type and inspect encryption, signatures, actions,69 attachments, links, page boxes, fonts, and page count.703. Decide whether the task is extraction, page transformation, annotation,71 redaction, generation, or reconstruction.724. For generation, establish the document type, audience, visual tone, page73 size, language coverage, font files, hierarchy, color tokens, and recurring74 components before writing rendering code. Read75 [`references/generation.md`](references/generation.md) for the required76 typography and layout workflow. The reusable77 [`assets/chinese-report.css`](assets/chinese-report.css) is a neutral starting78 point for polished Chinese or mixed Chinese/Latin reports, not a substitute79 for matching the operator's requested brand or style.805. Select the narrowest local backend that supports the operation.816. Produce a new output without activating links or embedded content.827. Reopen the result and check page count, dimensions, metadata, bookmarks,83 forms, attachments, encryption state, and expected text.848. Render every changed or generated page to images. Inspect the actual pages,85 not only the source HTML or drawing commands, and revise visible defects86 before delivery.879. For extraction or OCR, sample the output against rendered pages and record88 ambiguous tables, reading order, missing glyphs, and low-confidence text.8990## Quality Rules9192- Never rely on Helvetica, Times, or another Latin-only base font for Chinese,93 Japanese, or Korean text. Discover an appropriate local font, verify glyph94 coverage, and ensure fonts are embedded or otherwise reliably available in95 the produced PDF.96- Use a deliberate type scale, spacing rhythm, margins, line length, and color97 palette. A technically valid PDF with backend-default styling is not a98 finished generated document.99- For prose-heavy documents, prefer semantic flow layout over manually placing100 every line. Prevent headings, tables, figures, and callouts from splitting in101 visually confusing ways.102- Check rendered pages for missing-glyph boxes, substituted fonts, clipping,103 overlap, isolated headings, sparse spill pages, inconsistent spacing, weak104 contrast, and unreadably dense tables.105- Preserve intended page order, orientation, crop boxes, and dimensions.106- Distinguish visual redaction from secure content removal; verify that redacted107 text and related objects are not extractable.108- Do not infer table structure without checking coordinates and rendered pages.109- Retain source page references in extracted content when useful.110- Label OCR-derived text and do not silently replace uncertain characters.111- Verify links, bookmarks, forms, and signatures if the requested operation can112 affect them.113114## Delivery115116Report the output path, page range and operation, tools used, whether OCR or any117network service was used, structural and visual checks, signature or form118impact, font family and embedding status for generated documents, and extraction119or OCR limitations. State explicitly when active content was present but not120executed.