0.7.6 • Published 6 years ago

@react-pdf/core v0.7.6

Weekly downloads
35
License
MIT
Repository
github
Last release
6 years ago

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

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.render(<App />, document.getElementById('root'));

Node. Save in a file

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

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

Examples

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

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

FOSSA Status


npm.io

0.7.7-32

6 years ago

0.7.7-31

6 years ago

0.7.7-30

6 years ago

0.7.7-29

6 years ago

0.7.7-28

6 years ago

0.7.7-27

6 years ago

0.7.7-26

6 years ago

0.7.7-25

6 years ago

0.7.7-24

6 years ago

0.7.7-23

6 years ago

0.7.7-22

6 years ago

0.7.7-21

6 years ago

0.7.7-20

6 years ago

0.7.7-19

6 years ago

0.7.7-18

6 years ago

0.7.7-17

6 years ago

0.7.7-16

6 years ago

0.7.7-15

6 years ago

0.7.7-14

6 years ago

0.7.7-13

6 years ago

0.7.7-12

6 years ago

0.7.7-11

6 years ago

0.7.7-10

6 years ago

0.7.7-9

6 years ago

0.7.7-8

6 years ago

0.7.7-7

6 years ago

0.7.7-6

6 years ago

0.7.7-5

6 years ago

0.7.7-4

6 years ago

0.7.7-3

6 years ago

0.7.7-2

6 years ago

0.7.7-1

6 years ago

0.7.7-0

6 years ago

0.7.6

6 years ago

0.7.5

6 years ago

0.7.4

6 years ago

0.7.3

6 years ago

0.7.2

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.3

6 years ago

0.6.2

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.6

7 years ago

0.4.5

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.0

7 years ago