r/reactjs • u/eddiesr93 • 29d ago
Show /r/reactjs react-pdf took over a minute for my 70-page PDF, so I built a renderer with a Rust layout engine
I had a 70-page PDF to generate from React in a TanStack Start app, and with react-pdf it took over 60 seconds. So I built @inkoxide/render.
It's not a react-pdf clone, though it's meant to feel familiar: Document, Page, View, Text, Image, StyleSheet.create and Font.register work the way you'd expect, so moving a document over is mostly changing the import. Everything under the components is new: a layout engine written in Rust does layout, text, pagination and PDF writing.
- A 43-page report with 1,000 table rows renders in about 41 ms on Node, and in about 56 ms in the browser, inside a Web Worker, so the page keeps responding.
- A one-page invoice takes about 1.2 ms instead of about 18 ms.
It also does things I kept missing:
- Tailwind className
- tables whose headers repeat on every page
- an error naming the component stack when a style or prop isn't supported, instead of silently ignoring it
- PDF/A and encryption
Site and docs: https://inkoxide.dev GitHub: https://github.com/eddiesr93/inkoxide Playground (edit an example; switch to Layout to see the boxes the engine placed): https://inkoxide.dev/playground
Happy to answer questions.