Pdf tools

From stevehuang0115/crewly · View interactive version

Pdf tools is an AI agent skill from the GitHub repository stevehuang0115/crewly. Make polished PDFs from Markdown or styled HTML (headless Chrome preferred, WeasyPrint fallback, CJK-ready default stylesheet), merge several parts into one PDF, and read the text of a PDF someone sent you. When a dependency is missing it returns `needsSetup:true` — run `install-skill --id pdf-tools

How to use this skill

Skill file

PDF Tools

Make PDFs people like to read, and read the PDFs people send you.

Make a PDF (`render`)

# Markdown → PDF with the default A4 stylesheet (CJK fonts, tables, code, quotes)
bash {{AGENT_SKILLS_PATH}}/pdf-tools/execute.sh '{"action":"render","input":"/tmp/report.md","output":"/tmp/report.pdf","title":"Q3 报告"}'

# Your own styled HTML → PDF (kept exactly as you styled it)
bash {{AGENT_SKILLS_PATH}}/pdf-tools/execute.sh '{"action":"render","input":"/tmp/brief.html","output":"/tmp/brief.pdf"}'

# Several parts → one PDF, in order (.md / .html / .pdf)
bash {{AGENT_SKILLS_PATH}}/pdf-tools/execute.sh '{"action":"render","inputs":["/tmp/cover.html","/tmp/body.md","/tmp/appendix.pdf"],"output":"/tmp/full.pdf"}'

| Field | Default | Meaning |

|---|---|---|

| input / inputs | — | One file, or a list of parts merged in order |

| output | input path with .pdf | Where the PDF goes (required for several parts) |

| title | file name | Document title (Markdown only) |

| css | — | Extra stylesheet appended after the default one |

| addDefaultStyle | false | Also apply the default stylesheet to HTML input |

| engine | auto | auto (Chrome, else WeasyPrint), chrome, weasyprint |

| lang | zh | lang attribute of the generated HTML (font selection) |

Engines. Headless Chrome/Chromium renders exactly what a browser shows

(modern CSS, web fonts, CJK with system fonts) and is used whenever it is

installed. WeasyPrint is the fallback. Markdown goes through python-markdown

(or pandoc when the venv is missing).

Writing HTML for print. Use @page { size: A4; margin: 18mm }, and

<div class="page-break"></div> (default stylesheet) or break-after: page to

start a new page. For a cover page, render it as its own part and list it first.

Output: {"success":true,"pdf":"/tmp/report.pdf","size":48213,"parts":1,"engine":"chrome"}

Read a PDF (`read`)

bash {{AGENT_SKILLS_PATH}}/pdf-tools/execute.sh '{"action":"read","input":"/path/to/file.pdf"}'
bash {{AGENT_SKILLS_PATH}}/pdf-tools/execute.sh '{"action":"read","input":"/path/to/file.pdf","pages":"1-3,7","textFile":"/tmp/file.txt"}'

Returns {success, engine, pages, pagesRead, chars, text, truncated, textFile?}.

Text is split with --- page N --- markers. Long documents are cut at

maxChars (default 20000) — pass textFile to get everything on disk. A note

says when the PDF has no text layer (scanned images).

Other actions

Setup

Declared in skill.json → setup; install-skill --id pdf-tools (agents) or

crewly skills setup pdf-tools (terminal) installs what is missing:

Python venv ~/.crewly/venv/pdf-tools with pypdf, markdown and weasyprint;

optionally Chrome (Linux: chromium), Pango for WeasyPrint and Noto CJK fonts.

A missing dependency fails with "needsSetup": true, "skill": "pdf-tools" —

tell the user you are setting it up and run install-skill, don't give up.

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.