explaingit

lmn1919/dompdf.js

Analysis updated 2026-05-18

1,408TypeScriptAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

A browser based library that converts web pages into real vector PDFs using Rust and WebAssembly, without needing a server.

Mindmap

mindmap
  root((dompdf.js))
    What it does
      HTML to PDF conversion
      Vector text output
      Runs in the browser
    Tech stack
      TypeScript
      Rust
      WebAssembly
    Use cases
      Export long documents
      Add headers and footers
      Embed custom fonts
    Audience
      Frontend developers
      Web app builders

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Convert a long webpage into a multi-page PDF with selectable text.

USE CASE 2

Add repeating headers and footers to exported documents.

USE CASE 3

Embed custom fonts so non-English text renders correctly in the PDF.

USE CASE 4

Generate password protected, encrypted PDF files entirely client side.

What is it built with?

TypeScriptRustWebAssemblyWeb Workers

How does it compare?

lmn1919/dompdf.jsf/git-rewrite-commitsopenkursar/hello-halo
Stars1,4081,4111,423
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasyeasyeasy
Complexity2/52/53/5
Audiencedeveloperdeveloperpm founder

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Local development requires Node.js 18+ and the Rust toolchain with the wasm32-unknown-unknown target.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

dompdf.js is a JavaScript library that turns a webpage or part of a webpage into a PDF file, entirely inside the user's browser. Unlike many similar tools, it does not rely on the popular jsPDF library or on taking a screenshot of the page. Instead it uses Rust code compiled to WebAssembly to build a real vector PDF, meaning the text stays sharp at any zoom level and can be selected and copied, rather than being a flat image. The tool is aimed at long documents that need to be split across many pages, and it supports things like custom font embedding for non-English text, repeating headers and footers on every page, PDF compression, and password protection through encryption. Because everything runs in the browser, no server is needed to generate the file. Using it is meant to be simple: you point it at an element on the page, optionally turn on pagination and set a paper size, and it hands back a PDF file as a downloadable blob. Behind the scenes, the main part of the page is scanned, the work of preparing the render data is handed off to a background web worker so the page interface does not freeze, and the Rust based WebAssembly module writes the final PDF bytes. The project keeps a small number of options from an older, jsPDF based version of the tool for the sake of easier upgrades, though those specific options are accepted without actually doing anything in the new version. Setting it up locally requires Node.js and the Rust programming toolchain, since part of the project is compiled from Rust into WebAssembly during the build. The project is released under the MIT license, a permissive license that allows free use, including commercial use, as long as the copyright notice is kept.

Copy-paste prompts

Prompt 1
Show me how to convert a DOM element into a paginated PDF using dompdf.js.
Prompt 2
Explain how dompdf.js uses a web worker and WebAssembly to avoid freezing the page.
Prompt 3
Help me embed a custom font for Chinese text with dompdf.js.
Prompt 4
Compare dompdf.js's architecture to a screenshot based html2pdf approach.

Frequently asked questions

What is dompdf.js?

A browser based library that converts web pages into real vector PDFs using Rust and WebAssembly, without needing a server.

What language is dompdf.js written in?

Mainly TypeScript. The stack also includes TypeScript, Rust, WebAssembly.

What license does dompdf.js use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is dompdf.js to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is dompdf.js for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.