Component mapping
| react-pdf | Forme | Notes |
|---|---|---|
<Document> | <Document> | Same |
<Page> | <Page> | Same props, same behavior |
<View> | <View> | Same |
<Text> | <Text> | Same |
<Image> | <Image> | Same API, supports file paths and data URIs |
<Link> | Not yet supported | Use plain Text for now |
<Note> | Not yet supported | - |
<Canvas> | Not yet supported | - |
<SVG> | Not yet supported | - |
Import changes
react-pdf:StyleSheet.create() utility. Styles are plain objects passed directly to the style prop. If you prefer to define styles separately, use a regular JavaScript object:
Style differences
Most style properties are the same between react-pdf and Forme. Key differences:| Property | react-pdf | Forme |
|---|---|---|
fontWeight | "bold" or number | "bold", "normal", or number (100-900) |
borderWidth | Single number | Number or { top, right, bottom, left } |
borderColor | Single string | String or { top, right, bottom, left } |
borderRadius | Single number | Number or { topLeft, topRight, bottomRight, bottomLeft } |
margin | "auto" supported | "auto" not supported (use flexbox alignment instead) |
position | "absolute" supported | Use <Fixed> for repeating elements. Absolute positioning is not supported. |
Rendering
react-pdf:Uint8Array, react-pdf returns a Node.js Buffer.
Tables
react-pdf does not have a built-in Table component. Most projects use<View> with row/column flex layout to simulate tables. Forme has first-class table support:
react-pdf (common pattern):
Fixed headers and footers
react-pdf:Page numbers
react-pdf:What works better in Forme
- Page breaks. Flex containers, tables, and text all break correctly across pages. In react-pdf, flex layouts produce incorrect proportions after page splits.
-
Table header repetition. Mark a row as
headerand it repeats on every page. No workarounds needed. -
Dev server.
forme devgives you live preview with debug overlays and click-to-inspect. react-pdf requires rendering to a file and opening it manually. - Speed. Forme’s Rust/WASM engine renders in milliseconds. react-pdf is typically 5-10x slower for complex documents.
- Dependencies. Forme is a single WASM binary with no native dependencies. react-pdf depends on yoga-layout (native binary).
What works in react-pdf but not Forme (yet)
Be honest about these gaps before migrating:- SVG rendering. react-pdf has full SVG support. Forme does not render SVG elements. Workaround: convert SVGs to PNG/JPEG before embedding.
-
Links. react-pdf supports clickable links with
<Link>. Forme does not support PDF link annotations yet. -
Absolute positioning. react-pdf supports
position: "absolute". Forme only supports fixed headers/footers via<Fixed>, not arbitrary absolute positioning. - Bookmarks/outlines. react-pdf can generate PDF bookmarks. Forme does not support this yet.
-
Text run styling. react-pdf supports inline styling within text (e.g., bold a single word). Forme treats each
<Text>element as a single styled run. - Emoji rendering. react-pdf handles emoji via system fonts. Forme does not have special emoji support.
Migration checklist
- Replace
@react-pdf/rendererimports with@forme/reactand@forme/core - Remove
StyleSheet.create()calls (keep the style objects, just remove the wrapper) - Replace
fixedprop + absolute positioning with<Fixed position="header">or<Fixed position="footer"> - Replace render callbacks for page numbers with
{{pageNumber}}/{{totalPages}}placeholders - Convert View-based table layouts to
<Table>,<Row>,<Cell>components - Replace any SVG usage with rasterized images
- Remove any
<Link>components (or replace with styled Text for now) - Test page break behavior, especially for tables and flex layouts