Effortless PDF generation with React-style components and TypeScript.
Project details
RentnerPDF is a high-performance PDF engine designed for JavaScript and TypeScript. Leveraging a Rust core, it allows effortless document creation using React-style components and Tailwind-style classes. This engine delivers real pagination to generate standards-ready PDFs, providing a seamless integration experience on Node.js, Bun, and in browsers.
RentnerPDF is a powerful PDF engine designed for JavaScript and TypeScript applications, featuring a Rust core for exceptional performance. It allows users to create documents using React-style components and Tailwind-style class utilities, seamlessly integrating with modern web frameworks. The engine supports true pagination and generates standards-compliant PDFs natively on Node.js and Bun, as well as through WebAssembly on macOS and various web browsers.
@rentnerkev/pdf/react), or plain factory functions, all rendering byte-identical PDFs.className with Tailwind CSS v4 semantics, benefiting from features like IntelliSense and clsx for streamlined styling.Benchmarks showcase RentnerPDF’s efficiency:
| Focus Area | RentnerPDF | pdfmake | React-PDF |
|---|---|---|---|
| Invoice Generation: 10,000 invoices on 4 workers | 943 docs/s, 203 MiB | 75 docs/s, 1.23 GiB | 60 docs/s, 7.59 GiB |
| 500-page stats with running totals | 798 ms, 642 MiB | N/A | N/A |
| 100-page text report | 108 ms, 204 MiB | 681 ms, 589 MiB | 3.04 s, 1.69 GiB |
To write documents as components using the custom JSX runtime:
/** @jsxImportSource @rentnerkev/pdf */
import { writeFile } from 'node:fs/promises'
import { Document, Page, render, Text, View } from '@rentnerkev/pdf'
function Invoice({ number, total }: { number: string; total: string }) {
return (
<Document title={`Invoice ${number}`} lang="en">
<Page size="A4" className="p-page text-sm">
<View className="mb-8 flex justify-between">
<Text role="h1" className="text-2xl font-bold">
Invoice {number}
</Text>
<Text className="text-gray-500">Muster GmbH</Text>
</View>
<Text>Total: {total}</Text>
</Page>
</Document>
)
}
const pdf = await render(<Invoice number="2026-001" total="1.234,56 €" />)
await writeFile('invoice.pdf', pdf)
For comprehensive documentation, visit the usage guide for installation, engine details, component reference, styling, and advanced features. Additional resources include migration guides and benchmark reports for in-depth understanding and performance evaluation.
RentnerPDF is engineered for developers looking to create high-quality PDF outputs efficiently, utilizing the latest web technologies.
Comments
0Start the conversation
Share the first comment.