PDFs, made with React
open sourceMITself-hostablefree
@react-pdf/renderer (diegomura/react-pdf) is a React renderer that builds PDFs from components such as Document, Page, View, Text and Image, styled with a StyleSheet API. Layout uses Yoga, so pages get flexbox rows, columns, wrapping and absolute positioning. The same document renders in the browser (to the DOM, a blob or a download link) or in Node to a file or stream, with custom fonts, images, SVG, form fields, hyphenation and page-break control. It creates PDFs; it is not the wojtekmaj/react-pdf viewer for displaying existing ones.
Problems it solves
- build PDF documents out of React components instead of HTML strings
- my frontend team knows React and I want them to own the invoice PDF layout
- show a live preview of the generated PDF next to a form in our React app
- add a 'Download PDF' button in a Next.js app without a backend service
- the same PDF component should render in the browser and on our Node server
- lay out a resume or certificate with flexbox and get a real vector PDF, not a screenshot
- generate PDFs in a serverless function without bundling a headless browser
- repeat a fixed header on every page and break long tables across pages from JSX
- register custom fonts and embed SVG logos in a PDF made in TypeScript
Features
- React components for Document, Page, View, Text, Image and more
- StyleSheet API with flexbox layout via Yoga
- render in the DOM (PDFViewer), as a blob or download link, or to a file/stream in Node
- custom fonts
- images and SVG
- form fields
- hyphenation
- page-break control and fixed elements
Capabilities
| Has official SDKs | plan not known |
|---|
Alternatives
The same job
These do what @react-pdf/renderer does.
- DocSpring Fill PDF forms, generate PDFs and Word documents, and collect e-signatures with one API.
- jsPDF Client-side JavaScript PDF generation for everyone.
- pdf-lib Create and modify PDF documents in any JavaScript environment.
- pdfmake PDF document generation library for Node.js and browsers, written in pure JavaScript
- PDFKit A JavaScript PDF generation library for Node and the browser.
- Puppeteer JavaScript API for Chrome and Firefox
