React renderer for creating PDF files on the browser and server
How to install
yarn add @react-pdf/renderer
How it works
import React from 'react';import Document Page Text View StyleSheet from '@react-pdf/renderer'; // Create stylesconst styles = StyleSheet; // Create Document Componentconst MyDocument = <Document> <Page ="A4" => <View => <Text>Section #1</Text> </View> <View => <Text>Section #2</Text> </View> </Page> </Document>;
Web.
Render in DOM
import React from 'react';import ReactDOM from 'react-dom';import PDFViewer from '@react-pdf/renderer'; const App = <PDFViewer> <MyDocument /> </PDFViewer>; ReactDOM;
Node.
Save in a file
import React from 'react';import ReactPDF from '@react-pdf/renderer'; ReactPDF;
Examples
For each example, try opening output.pdf
to see the result.
Text |
Images |
Resume |
Fractals |
Knobs |
Page wrap |
To run the examples, first clone the project and install the dependencies:
git clone https://github.com/diegomura/react-pdf.gitcd react-pdfyarn install
Then, run yarn example -- <example-name>
yarn example -- fractals
Contributors
This project exists thanks to all the people who contribute. [Contribute].
Sponsors
Thank you to all our sponsors! [Become a sponsors]
Backers
Thank you to all our backers! [Become a backer]
License
MIT © Diego Muracciole