Skip to content

mattstates/react-pdf

This branch is 755 commits behind diegomura/react-pdf:master.

Folders and files

NameName
Last commit message
Last commit date
Feb 21, 2018
Aug 4, 2018
Jul 13, 2018
Aug 2, 2018
Aug 3, 2018
Jan 18, 2018
Jul 24, 2018
May 6, 2017
Jul 13, 2018
Jan 19, 2018
Sep 12, 2017
Jan 17, 2018
Jun 19, 2017
Oct 25, 2017
May 20, 2017
Aug 4, 2018
May 20, 2017
Aug 5, 2018
Aug 3, 2018
Aug 3, 2018

Repository files navigation

React renderer for creating PDF files on the browser, mobile and server

npm Travis license Join the community on Spectrum styled with prettier

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 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>
);

Render in DOM

import React from 'react';
import ReactDOM from 'react-dom';

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

Save in a file

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

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

Render in mobile

Coming soon

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.git
cd react-pdf
yarn 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

About

πŸ“„ Create PDF files using React

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%