gitmyhub

taepdf

TypeScript ★ 4 updated 11d ago

Browser-based HTML-to-PDF engine that captures your page's exact rendered layout and turns it into a real, pixel-perfect PDF – no server, no headless browser.

taepdf turns HTML and CSS into a pixel-perfect PDF entirely inside the browser, using a Rust and WebAssembly engine that reads the page's real rendered layout, with no server or headless browser needed.

TypeScriptRustWebAssemblysetup: easycomplexity 2/5

taepdf is a browser-based tool that turns HTML and CSS into a real PDF file. Instead of running on a server or spinning up a hidden browser instance, it works entirely inside the user's own browser tab, reading the exact position, size, color, and font of every element straight from the page's DOM, then handing that information to a Rust and WebAssembly engine that rebuilds it as a PDF. Because it reads what the browser has already rendered, the PDF matches the on-screen layout pixel for pixel, with no separate layout engine trying to guess at the result.

The library is browser-only by design. It depends on DOM functions that simply do not exist in Node.js, Bun, Electron, Tauri, or any server-side rendering environment, so it cannot run in those contexts. If a project uses a framework like SvelteKit, Next.js, or Nuxt, the code that calls taepdf has to run specifically on the client side. It also ships only as modern ES modules, with no older CommonJS version, though current bundlers like Vite, webpack, and esbuild handle that automatically.

Getting started is a single npm install followed by one import line, after which the engine begins preparing itself automatically. There is no separate WASM setup, font registration, or build plugin configuration required. A companion command line tool, run with npx taepdf, generates a starter template file for a document, which a developer then edits to describe their own PDF layout in HTML.

A typical project ends up with two small custom files: a template function that turns data into an HTML string, and a small export utility that passes that HTML to the library's download function along with a filename and page size. The same template can also power a live, in-browser preview of the document before it is exported, so the layout only needs to be designed once. The README goes on to cover topics like pagination, headers and footers, right-to-left text, interactive forms, and framework-specific setup guides. The full README is longer than what was shown.

Where it fits