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.

invoice.tsx
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.

FeatureFormereact-pdf
Bring existing HTML/CSSYes (@formepdf/html)No (JSX only)
Line breakingKnuth-PlassKnuth-Plass
Text shapingOpenType GSUB/GPOS (rustybuzz)OpenType GSUB/GPOS (fontkit)
BiDi textRTL, mixed LTR/RTL (unicode-bidi)RTL, mixed LTR/RTL (bidi-js)
HyphenationAutomatic, 35+ languages bundledAutomatic (en-US bundled)
Page breaksPage-native layout (widows/orphans)Widows/orphans (recent rewrite)
Table headersAutomatic on every pageNot built in
CSS GridComponent API: display 'grid', fr/auto/fixed tracksNo
Charts5 built-in components, engine-native vectorsNo (hand-rolled SVG)
QR codesBuilt-in <QrCode> componentNo
BarcodesBuilt-in <Barcode> (5 formats)No
Live previewBuilt-in dev serverRender to file
Editor extensionVS Code sidebar panelsNo
PDF/A archival conformancePDF/A-2, A-3, A-4/A-4f — veraPDF-verified, composes with PDF/UA-1 and UA-2No
Digital certificationcertifyPdf() — PKCS#7/RSA, pure RustNo
True redactionredactText() — literal/regex, content-stream removalNo
PDF mergingmergePdfs() in @formepdf/coreNo
Browser renderingYes (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.