agentleFS
Astro-HanAstro-Han/pawwork/skills/office-pdf/SKILL.md

office-pdf

Skill206 starsChanged 3 months agoApache-2.0View on GitHub

PDF parsing (uv + pdfplumber / pypdf): use this for reading or extracting text/tables from any PDF. PDF generation (author print-ready HTML, then print with PawWork's bundled Chromium) is best-effort — where the runtime exposes no print entry point, report that generation is unavailable rather than substituting another tool. Hard rule: never use PyMuPDF / fitz (AGPL).

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. bushuhui/skills★ 2same name
    2. hacker943410-debug/ai-harness★ 2same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use page-break-before/after / break-inside: avoid to control pagination.

    line 28
  2. Distinctive:

    Prefer real text and CSS/SVG vector graphics over rasterized screenshots so the PDF stays selectable and crisp.

    line 29
  3. Distinctive:

    If text extraction returns empty, the PDF is likely scanned images — say so and stop.

    line 56

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

office-pdf — generate and parse PDF

Two independent paths: generate a PDF from HTML using PawWork's bundled Chromium, and parse an existing PDF with permissively-licensed Python libraries.

License hard rule (non-negotiable)

Never use PyMuPDF / fitz / pymupdf — it is AGPL and must not enter the product. Also avoid any tool that shells out to it. Allowed parsers are pdfplumber (MIT) and pypdf (BSD) only. For rendering, use the bundled Chromium — not wkhtmltopdf, not LibreOffice, not a system-installed browser.

Runtime contract

  • uv must be on PATH for the parse path. Parsing runs through uv run; the runtime injects the package-mirror environment variables so uv resolves pdfplumber / pypdf from the internal mirror. You do not configure the mirror.
  • If uv is missing (parse path), stop and report exactly: office-pdf parsing requires 'uv' on PATH, but 'uv --version' failed. This is an environment problem — uv should be provisioned by the PawWork runtime. Do not fall back to system pip; report the missing uv instead.
  • The skill directory ships read-only inside the app bundle. Never write into it. Work in a fresh directory.

Path 1 — Generate (HTML → Chromium printToPDF)

PawWork bundles its own Chromium; the PDF is produced by that engine's Page.printToPDF (Chrome DevTools Protocol) driving your HTML. No external browser install, no wkhtmltopdf, no LibreOffice.

Author a self-contained HTML file built for print:

  • Set page geometry with @page { size: A4; margin: 18mm; } (or Letter, or an explicit size: 210mm 297mm).
  • Inline all CSS and, where practical, images (as data: URIs) so the page renders without network fetches.
  • Use page-break-before/after / break-inside: avoid to control pagination; design against print CSS, not screen scroll.
  • Prefer real text and CSS/SVG vector graphics over rasterized screenshots so the PDF stays selectable and crisp.

Then render it to PDF through the runtime's bundled-Chromium print entry point (Page.printToPDF over the browser bridge). If the current build exposes no PDF/print tool, report that the generation path is not available in this runtime rather than shelling out to an unbundled browser or an AGPL library — this can happen while the bundled-Chromium print entry point is still being wired up, so degrade gracefully instead of substituting another tool.

Path 2 — Parse (uv + pdfplumber / pypdf)

SKILL_DIR is the skill's base directory as a plain filesystem path — copy the line labeled "Base directory as a plain filesystem path" from the skill-load output. Do not use the file:// URL form; if only a file:// URL is available, strip the file:// prefix first.

SKILL_DIR="<plain filesystem path from the skill-load output, no file:// prefix>"
uv --version >/dev/null 2>&1 || { echo "office-pdf parsing requires 'uv' on PATH, but 'uv --version' failed. This is an environment problem — uv should be provisioned by the PawWork runtime. Do not fall back to system pip; report the missing uv instead."; exit 1; }
mkdir -p work && cp "$SKILL_DIR/pyproject.toml" work/pyproject.toml   # pdfplumber (MIT) + pypdf (BSD)

The shipped pyproject.toml pins both parsers so either import resolves offline, but you only need one per task — choose by need, both run from work/:

  • pdfplumber — layout-aware text and table extraction; use when you need columns, tables, or word positions.
    uv run python -c "import pdfplumber,sys; \
    [print(p.extract_text() or '') for p in pdfplumber.open(sys.argv[1]).pages]" input.pdf
  • pypdf — fast plain-text, metadata, page count, and split/merge; use for quick text or manipulation.
    uv run python -c "from pypdf import PdfReader; import sys; r=PdfReader(sys.argv[1]); \
    print(len(r.pages), 'pages'); print(r.pages[0].extract_text())" input.pdf

If text extraction returns empty, the PDF is likely scanned images — say so and stop; do not reach for PyMuPDF or any AGPL OCR-render path.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.