Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/diegomura/react-pdf

๐Ÿ“„ Create PDF files using React
https://github.com/diegomura/react-pdf

flexbox pdf react renderer

Last synced: 3 days ago
JSON representation

๐Ÿ“„ Create PDF files using React

Awesome Lists containing this project

README

        



React renderer for creating PDF files on the browser and server


















## Lost?

This package is used to _create_ PDFs using React. If you wish to _display_ existing PDFs, you may be looking for [react-pdf](https://github.com/wojtekmaj/react-pdf).

## How to install

```sh
yarn add @react-pdf/renderer
```

## How it works

```jsx
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 = () => (



Section #1


Section #2



);
```

### `Web.` Render in DOM

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

const App = () => (



);

ReactDOM.render(, document.getElementById('root'));
```

### `Node.` Save in a file

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

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

## Contributors

This project exists thanks to all the people who contribute. Looking to contribute? Please check our [[contribute]](https://github.com/diegomura/react-pdf/blob/master/.github/CONTRIBUTING.md) document for more details about how to setup a development environment and submitting code.

## Sponsors

Thank you to all our sponsors! [[Become a sponsors](https://opencollective.com/react-pdf#sponsors)]

## Backers

Thank you to all our backers! [[Become a backer](https://opencollective.com/react-pdf#backer)]

## License

MIT ยฉ [Diego Muracciole](http://github.com/diegomura)

---

![](https://img.shields.io/npm/dt/@react-pdf/renderer.svg?style=flat)