@react-pdf/renderer
TypeScript icon, indicating that this package has built-in type declarations

4.3.0 • Public • Published

React renderer for creating PDF files on the browser and server

How to install

yarn add @react-pdf/renderer

How it works

import { Document, Page, Text, View, StyleSheet } from '@react-pdf/renderer';

// Create styles
const styles = StyleSheet.create({
  page: {
    flexDirection: 'row',
    backgroundColor: '#E4E4E4',
  },
  section: {
    margin: 10,
    padding: 10,
    flexGrow: 1,
  },
});

// Create Document Component
const MyDocument = () => (
  <Document>
    <Page size="A4" style={styles.page}>
      <View style={styles.section}>
        <Text>Section #1</Text>
      </View>
      <View style={styles.section}>
        <Text>Section #2</Text>
      </View>
    </Page>
  </Document>
);

Web. Render in DOM

import ReactDOM from 'react-dom';
import { PDFViewer } from '@react-pdf/renderer';

const App = () => (
  <PDFViewer>
    <MyDocument />
  </PDFViewer>
);

ReactDOM.render(<App />, document.getElementById('root'));

Node. Save in a file

import ReactPDF from '@react-pdf/renderer';

ReactPDF.render(<MyDocument />, `${__dirname}/example.pdf`);

Examples

For each example, try opening output.pdf to see the result.


Text

Resume

Fractals

Knobs

Page wrap

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

FOSSA Status


Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
4.3.0189,302latest

Version History

VersionDownloads (Last 7 Days)Published
4.3.0189,302
4.2.42,030
4.2.3228
4.2.215,170
4.2.112,335
4.2.02
4.1.631,141
4.1.514,572
4.1.44,894
4.1.354
4.1.22,247
4.1.14
4.1.0527
4.0.2595
4.0.1279
4.0.036,430
3.4.5126,493
3.4.476,870
3.4.31,140
3.4.211,941
3.4.1474
3.4.02,111
3.3.814,189
3.3.7447
3.3.681
3.3.51,304
3.3.43,278
3.3.3217
3.3.2264
3.3.11,189
3.3.060
3.2.15,611
3.2.0655
3.1.172,963
3.1.1657
3.1.152,220
3.1.1461,458
3.1.131,990
3.1.1235,101
3.1.111,320
3.1.10256
3.1.913,897
3.1.8661
3.1.7713
3.1.61,213
3.1.51,432
3.1.41,980
3.1.31,592
3.1.21,389
3.1.11,040
3.1.06
3.0.31,284
3.0.24,146
3.0.11,615
3.0.04,407
2.3.012,882
2.2.01,165
2.1.2268
2.1.14,523
2.1.02,231
2.0.211,729
1.6.1711,782
2.0.20576
2.0.191,163
2.0.18486
2.0.1766
2.0.16373
2.0.15768
2.0.14219
2.0.13277
2.0.12240
2.0.110
2.0.100
2.0.91
2.0.841
2.0.723
2.0.6124
2.0.5194
2.0.475
2.0.30
2.0.21
2.0.10
2.0.024
2.0.0-beta.251
2.0.0-beta.240
2.0.0-beta.231
1.6.16863
2.0.0-beta.220
2.0.0-beta.210
1.6.153
2.0.0-beta.201
2.0.0-beta.190
1.6.14214
1.6.13603
2.0.0-beta.183
2.0.0-beta.1749
1.6.12627
2.0.0-beta.160
2.0.0-beta.150
1.6.111,288
2.0.0-beta.1422
2.0.0-beta.130
2.0.0-beta.120
2.0.0-beta.110
1.6.10197
2.0.0-beta.6177
1.6.9189
2.0.0-beta.50
2.0.0-beta.40
2.0.0-beta.30
2.0.0-beta.20
2.0.0-beta.01
1.6.83,761
1.6.7211
1.6.619
1.6.50
1.6.4300
1.6.355
1.6.29
1.6.14
1.6.036
1.5.679
1.5.50
1.5.4613
1.5.32
1.5.22
1.5.10
1.5.00
1.4.20
1.4.11
1.4.01
1.3.40
1.3.30
1.3.22
1.3.10
1.3.01
1.2.30
1.2.22
1.2.13
1.2.02
1.1.11
1.1.00
1.0.08
1.0.0-alpha.250
1.0.0-alpha.240
1.0.0-alpha.230
1.0.0-alpha.220
1.0.0-alpha.210
1.0.0-alpha.200
1.0.0-alpha.190
1.0.0-alpha.182
1.0.0-alpha.171
1.0.0-alpha.160
1.0.0-alpha.150
1.0.0-alpha.140
1.0.0-alpha.130
1.0.0-alpha.120

Package Sidebar

Install

npm i @react-pdf/renderer

Weekly Downloads

632,137

Version

4.3.0

License

MIT

Unpacked Size

265 kB

Total Files

17

Last publish

Collaborators

  • diegomura