Paged.js JavaScript pagination library for previewing and producing print-oriented documents with browser technology.
Overview Paged.js is a JavaScript library that paginates HTML content for print-oriented output. It translates supported paged-media CSS into structures and styles a browser can render, providing an on-screen page preview that can be saved as PDF. It is an MIT-licensed library with an associated command-line renderer, rather than a standalone desktop publishing editor.[1] [2] [4]
Contents A browser-centered workflow The library fragments content into pages and presents the result in a browser, allowing a designer to inspect the layout with familiar browser tools. Its polyfill approach implements selected print-oriented behavior on top of browser rendering rather than replacing the entire browser engine. This workflow can be useful for documents authored as HTML, but should not be confused with importing an arbitrary desktop-publishing project.[1]
Preparing content before pagination The repository exposes a Previewer interface and a polyfill that normally starts after the document is ready. Applications can delay that start with an asynchronous preparation step or invoke pagination explicitly. Handler hooks also allow custom work during parsing and layout. These controls matter when content needs preparation before pages are formed; changing the input after pagination is a separate concern from producing a completed preview.[2]
Generated navigation content CSS-generated content can add labels, counters and printed link text without placing those strings directly in the source content. Paged.js's documentation connects this approach with running headers, page numbers and cross-references for paginated documents. Such layout-generated material belongs to the output presentation. A reusable content source and its final paginated reading aids should therefore be treated as related but distinct artifacts.[3]
Command-line rendering and resources The associated command-line project combines Paged.js with Puppeteer to render HTML as PDF. It exposes options for timeouts, page dimensions, additional scripts and controlling access to local or remote resources. This makes browser automation part of the production environment. The documented controls provide configuration choices, not proof that an untrusted document is safe under every default deployment.[4]
Substitution considerations Paged.js can substitute for WeasyPrint for compatible HTML/CSS publishing jobs when a browser-based preview and rendering workflow is desired. WeasyPrint uses its own Python pagination engine, so matching the input language does not imply matching layout, dependencies or extension behavior. A switch should compare the required print features and actual output, retaining control of when pagination begins and which resources the renderer may access.[1] [2] [4] [5]
Also included: 3 capabilities and 0 substitute relationships. Check substitutes in section 1 and capabilities in section 3.