pagedjs
HTML/CSS print layout with Paged.js (paged media, breaks, counters. running headers/footers) for producing book PDFs.
- License 许可
- MPL-2.0
- 最近更新
- 2026-11-13
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- pagedjs
- updated
- 1789430400000
- description
- HTML/CSS print layout with Paged.js (paged media, breaks, counters. running headers/footers) for producing book PDFs.
- when_to_use
- Use when designing or debugging HTML/CSS layouts rendered with Paged.js, especially for pagination, running headers/footers, counters, and print-specific layout failures.
03 SKILL.md 正文
Paged.js
Use this skill to design and debug HTML/CSS layouts rendered with Paged.js.
Establish the runtime first
Record the exact Paged.js version and rendering path (polyfill, API, CLI, or a
wrapper such as gutterpress) before diagnosing a layout problem. Paged.js
0.4.3's published feature table supports break-inside: avoid, but not
break-inside: avoid-page; later prereleases and custom handlers can behave
differently. Reproduce against the project's pinned version.
A consumer may provide knowledge/print/pagedjs-failure-modes with verified
project-specific failures. Load it when present, but apply its workarounds only
to the runtime it documents. A data-break-inside="avoid" attribute, for
example, has no built-in meaning unless that pipeline registers a handler for
it.
Core Loop
- Edit HTML/CSS.
- Preview in browser with Paged.js.
- Fix fragmentation/layout issues.
- Render PDF.
- Review PDF, iterate.
Common Tasks
- Page setup:
@pagesize/margins, recto/verso variants. - Fragmentation:
break-before/after,break-inside: avoid,orphans, andwidows; verify the rendered result because support varies by element and version. - Running headers/footers:
string-set+ margin boxes. - Counters: page numbers, chapter counters.
Compatibility constraints
- Prefer selectors supported by the project's pinned Paged.js version. Test advanced selectors such as
:has()with a minimal reproduction before using them in a production book. - Use
break-inside: avoidfor the standard keep-together case. Do not substituteavoid-page, which Paged.js 0.4.3 does not support. Oversized elements still must be allowed to split. - Treat left/right placement as a rendered-output assertion. Front matter, blank pages, and custom handlers can shift the apparent spread, so inspect page numbers and facing pages instead of assuming parity from a class name alone.
- A custom
data-*workaround is portable only with the handler that implements it. Document and load that handler before relying on the attribute.
Scripts
- Validate:
python skills/print/pagedjs/scripts/validate_pagedjs.py document.html --css styles.css - Minimal repro:
python skills/print/pagedjs/scripts/preview_template.py --css styles.css --output preview.html
References
- Paged.js supported-feature table: https://pagedjs.org/en/documentation/14-supported-feature-of-the-w3c-specifications/
- Optional consumer failure modes:
knowledge/print/pagedjs-failure-modes - Patterns:
skills/print/pagedjs/references/css-patterns.md - Troubleshooting:
skills/print/pagedjs/references/troubleshooting.md
04 同仓库更多 Skills
tax-filing-checklist
Walk through the steps and documents needed to file an individual federal income tax return
patient-vitals-charting
Record patient vital signs consistently and flag values outside the normal reference range
pasta-from-scratch
Make fresh egg pasta dough from scratch, roll it, and cut it into shapes
knife-sharpening
Sharpen and hone kitchen knives to keep an edge safe and effective
first-aid-response
Respond to a first aid emergency using a scene-safety-first, ABC-based (airway, breathing, circulation) approach
contract-review-basics
Review a contract draft for missing terms, ambiguous language, and risky clauses before signing