react-pdf alternative
A react-pdf alternative with HTML input and page-native layout
react-pdf is a good library, and Forme's component API will feel familiar. Both do Knuth-Plass line breaking and OpenType shaping. The differences are in what's around the components: an HTML input path, layout that reacts to page boundaries, and conformance features.
import { Document, Page, View, Text } from '@formepdf/react';
import { renderDocument } from '@formepdf/core';
const pdf = await renderDocument(
<Document>
<Page size="Letter" margin={36}>
<Text style={{ fontSize: 24, fontWeight: 'bold' }}>
Invoice #2024-001
</Text>
</Page>
</Document>
);Familiar Document, Page, View, Text, Image, Table — the component model you know.
Also HTML Render existing HTML and print CSS through @formepdf/html.
MIT licensed, like react-pdf.
The real difference
Layout that knows where the page ends
react-pdf lays content out on an infinite canvas and slices it into pages afterward, so layout can't react to the page boundary. Forme flows content into pages as it lays them out.
Repeating table headers
Header rows repeat on every page automatically, and cell content is preserved across breaks. react-pdf doesn't build this in.
Page-aware flex
Flex calculations use the actual page-constrained dimensions, so a row that won't fit moves to the next page instead of being cut.
CSS Grid
2D grid layout with fixed, fractional, and auto tracks in the component API. react-pdf has no grid.
HTML input path
If some documents are already HTML, render them with the same engine instead of rewriting them as components.
Comparison
Forme vs react-pdf, row by row
Where they match, the table says so.
| Feature | Forme | react-pdf |
|---|---|---|
| Bring existing HTML/CSS | Yes (@formepdf/html) | No (JSX only) |
| Line breaking | Knuth-Plass | Knuth-Plass |
| Text shaping | OpenType GSUB/GPOS (rustybuzz) | OpenType GSUB/GPOS (fontkit) |
| BiDi text | RTL, mixed LTR/RTL (unicode-bidi) | RTL, mixed LTR/RTL (bidi-js) |
| Hyphenation | Automatic, 35+ languages bundled | Automatic (en-US bundled) |
| Page breaks | Page-native layout (widows/orphans) | Widows/orphans (recent rewrite) |
| Table headers | Automatic on every page | Not built in |
| CSS Grid | Component API: display 'grid', fr/auto/fixed tracks | No |
| Charts | 5 built-in components, engine-native vectors | No (hand-rolled SVG) |
| QR codes | Built-in <QrCode> component | No |
| Barcodes | Built-in <Barcode> (5 formats) | No |
| Live preview | Built-in dev server | Render to file |
| Editor extension | VS Code sidebar panels | No |
| PDF/A archival conformance | PDF/A-2, A-3, A-4/A-4f — veraPDF-verified, composes with PDF/UA-1 and UA-2 | No |
| Digital certification | certifyPdf() — PKCS#7/RSA, pure Rust | No |
| True redaction | redactText() — literal/regex, content-stream removal | No |
| PDF merging | mergePdfs() in @formepdf/core | No |
| Browser rendering | Yes (same WASM engine) | Yes (client-side) |
Corrections welcome — open an issue if a row is out of date.
react-pdf comparison questions
- How does Forme compare to react-pdf?
- The component API will feel familiar, and both do Knuth-Plass line breaking and OpenType shaping. Forme adds an HTML input path, CSS Grid in the component API, table headers that repeat across pages, verified PDF/UA-1 and PDF/UA-2 output, certification, and true redaction. react-pdf is JSX-only.
- Is migrating from react-pdf a rewrite?
- Mostly a rename. Document, Page, View, Text, and Image map across, and styles are objects in both. Review layouts that depended on react-pdf slicing a long page, since Forme breaks pages during layout instead. The migration guide maps each component and what to watch for.
- Does Forme work in the browser like react-pdf?
- Yes. The same WASM engine renders client-side, so a preview in the browser matches the server output.