Spa to pdf
AI 工作流 Skill 合集:办公、研究、归档、日报、尽调、文档转换等可复用工作流
npx -y skills add Jim4546/ai-workflow-skills --skill spa-to-pdfAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Scrape a single-page-app (SPA) website with multiple collapsible/sectioned content blocks and produce a Word document plus a PDF with an auto-filled table of contents and clickable inline hyperlinks. Use when the user provides a SPA URL (hash routes, JS-rendered content) and asks for a Word/PDF export of all sections. Requires Windows + Microsoft Word for the final PDF step.
SKILL.md
3.8 KB, 879 tokens by cl100k_base, as published. Nobody here has run it
spa-to-pdf
Turn a JS-rendered SPA page (e.g. https://example.com/#/some/section) into:
output.docx— cover, bilingual TOC, every section as Heading 1 with original paragraphs/lists/hyperlinks preservedoutput.pdf— same, with TOC fields filled and heading bookmarks
When to invoke
Trigger this skill when the user asks to "scrape / save / export / archive a
website's content into Word or PDF" AND the site looks like a SPA (URL has
#/..., content is dynamic, or curl returns an empty shell). For plain
static HTML pages, a simpler WebFetch + pandoc pipeline is enough — skip
this skill there.
Prerequisites
- Python 3.10+
- Windows + Microsoft Word installed (needed for PDF + TOC fields)
- One-time setup:
python -m venv .venv .\.venv\Scripts\Activate.ps1 pip install playwright python-docx beautifulsoup4 lxml pywin32 playwright install chromium
Pipeline
Run the four scripts in scripts/ in order. They share a working dir (defaults
to ./raw/ for intermediate files and ./output.docx, ./output.pdf for
products). All scripts take CLI args — see --help on each.
1. Probe (optional but recommended)
python scripts/probe.py <URL>
Dumps the rendered HTML and the top CSS class names. Use the output to pick selectors for step 2. If the page is a typical Collapsible-based site (e.g. World Scholar's Cup themes), the defaults already work.
2. Scrape
python scripts/scrape.py <URL> `
--section-selector .Collapsible `
--title-selector .Collapsible__trigger `
--content-selector .Collapsible__contentInner
Writes raw/index.json with {root_url, page_title, subtitle, sections: [{title, html, links}]}.
3. Build Word
python scripts/build_doc.py --in raw/index.json --out output.docx
4. Verify
python scripts/verify.py --in raw/index.json --docx output.docx
Exits 0 if every section's character count, hyperlink count, and word set roughly matches the source HTML. If not, the script prints what's missing per section. Always run this before showing the doc to the user.
5. Export PDF
python scripts/to_pdf.py output.docx output.pdf
Opens Word, updates TOC fields + bookmarks, exports PDF, closes Word.
Important behaviors
- Inline links only. Do NOT visit each outbound link and append its content — the source page already places the links inline with context; duplicating the targets bloats the doc and adds noise.
- No
add_page_break(). Useparagraph_format.page_break_before = Trueon Heading 1 — manual page breaks cause trailing blank pages when content happens to fill a page. - TOC page title must NOT be Heading 1. Otherwise the TOC contains itself.
Use a plain styled paragraph (see
build_doc.py). - Always run
verify.pybefore reporting success. It catches missing nested lists, dropped runs, and character-encoding bugs that aren't visible at a glance.
For the full list of edge cases and why each fix exists, read
references/pitfalls.md. Read it before changing any of the scripts —
several of the "obvious" simplifications will reintroduce bugs we already
fixed.
Cross-platform note
The PDF step depends on pywin32 and Microsoft Word. On macOS this can be
ported to AppleScript / appscript; on Linux, use LibreOffice headless with
a TOC-update macro. PRs welcome.
Gives 0 of the 12 instructions most pdf office docs skills give in 879 tokens
Counted across 636 of the 690 authors here whose files we hold, read 2026-08-07
- extract text using pdfplumberin 89 of 636, across 23 files
- create PDFs using reportlabin 83 of 636, across 16 files
- read forms.md to fill out pdf formsin 80 of 636, across 13 files
- OCR scanned PDFs using pytesseractin 77 of 636, across 10 files
- merge or split PDFs using qpdfin 70 of 636, across 3 files
- use excel formulas instead of hardcoded calculated valuesin 68 of 636, across 13 files
- unpack edit xml and repack existing documentsin 63 of 636, across 8 files
- document sources for hardcoded valuesin 61 of 636, across 9 files
- write minimal python code without unnecessary commentsin 59 of 636, across 7 files
- run the recalculation script after adding or modifying formulasin 59 of 636, across 7 files
- fix all identified formula errors and recalculatein 58 of 636, across 6 files
- format years as text stringsin 57 of 636, across 5 files
Said here and by no other author read
- skip this skill for plain static HTML pages
- run the probe script to pick selectors
- write scraped data to raw/index.json
- build a Word document from the scraped JSON
- run verify.py before reporting success
- use paragraph_format.page_break_before for page breaks
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.