PDF document creation is stuck in the past, from clunky Word docs to complex LaTeX to outdated tools. htmldocs brings document generation into 2025 with a modern developer experience using the tools you already love: React, TypeScript, and Tailwind.
htmldocs is a local document editor and preview server to help you create PDFs with React. It provides all the structural benefits of LaTeX with the familiarity of HTML and CSS. With htmldocs, you can use JSX to build document templates (invoices, reports, contracts, etc.) and generate PDFs just by passing data as props. htmldocs has:
- π Support for the latest CSS features like margin boxes and flexbox
- 𧩠A collection of unstyled components to help you layout your documents
- π JSX templating system for building dynamic documents
- π Full TypeScript support for type safety
- β‘ Dynamic data integration through props and APIs
- π Real-time preview server with hot reloading
To see the full power of htmldocs, here is how you might build a dynamic invoice document template with JSX template variables:

To change the customer details, all you need to do is render the Invoice
component with different props:
<Invoice
customer={{
name: "John Doe",
address: "456 Main St",
city: "Anytown",
state: "CA",
zip: "12345",
phone: "123-456-7890",
}}
items={items}
/>
To create your first htmldocs project, run the following command:
npx htmldocs@latest init
For further instructions or to integrate htmldocs into your existing project, refer to the Getting Started guide.
htmldocs comes with a standard set of components to help you layout and style your documents.
htmldocs is built upon Chromium's rendering engine, which means it can render any HTML, CSS, and JavaScript. This is different from other tools like wkhtmltopdf, WeasyPrint, and Prince, which only support a subset of HTML and CSS.
htmldocs also uses the Paged.js library under the hood. Paged.js is used for layout and chunking, as well as more modern features like margin boxes that aren't fully supported by the W3C's CSS standard.
Feature | Traditional Documents (Word, Google Docs) |
LaTeX Documents (Overleaf, TeXStudio) |
Freeform Documents (Figma, Sketch) |
Web Documents (htmldocs) |
---|---|---|---|---|
Content Structure | Semi-Structured | Structured | Freeform | Structured |
Learning Curve | β Simple | β Complex | β Simple | β Simple |
Template Variables | β Limited | β Limited | β Limited | β Supported |
Styling | β Basic | β Complex | β Advanced | β Advanced |
Version Control | β Limited | β Supported | β Limited | β Supported |
External Libraries | β Limited | β Supported | β Limited | β Supported |
Automation / API | β Limited | β Limited | β Limited | β Supported |
Live Preview | β Supported | β Limited | β Supported | β Supported |
CI/CD Integration | β Limited | β Limited | β Supported | |
Type Safety | β Limited | β Limited | β Limited | β Supported |
AI | β Limited | β Limited | β Limited | β Supported |
![]() |
![]() |
||
---|---|---|---|
Next.js | TypeScript | Turborepo | pnpm |
MIT License