Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/bkniffler/react-pdfmake

https://react-pdfmake.netlify.app
https://github.com/bkniffler/react-pdfmake

Last synced: about 1 month ago
JSON representation

https://react-pdfmake.netlify.app

Awesome Lists containing this project

README

        


react-pdfmake


react-pdfmake


Super easy way to create PDFs through react components.





Build Status


Coverage Status


Version


Language


License





## Demo

https://react-pdfmake.netlify.app

## Install

Careful, pdfmake is now a peerDependency.

### Yarn

```
yarn add react-pdfmake pdfmake
```

### NPM

```
npm i react-pdfmake pdfmake
```

## Example

```jsx
import React from 'react';
import {
PDFDocument,
PDFText,
PDFTable,
PDFTableRow,
PDFTableColumn,
PDFColumn,
PDFColumns,
pdf,
} from 'react-pdfmake';

export default function Home() {
const file = React.useMemo(() => {
return pdf(
{
return (
currentNode.headlineLevel === 1 && followingNodesOnPage.length === 0
);
}}
styles={{
header: {
fontSize: 18,
bold: true,
margin: [0, 0, 0, 10],
},
subheader: {
fontSize: 16,
bold: true,
margin: [0, 10, 0, 5],
},
tableExample: {
margin: [0, 5, 0, 15],
},
tableHeader: {
bold: true,
fontSize: 13,
color: 'black',
},
}}
>
Headers
You can declare how many rows should be treated as a header. Headers are
automatically repeated on the following pages

Headers


Hi
Hi



Header 1
Header 2
Header 3



Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum




);
}, []);
return (
<>
file.print()}>Print PDF
file.download()}>Download PDF
file.open()}>Open PDF
>
);
}
```

## Credits

- [pdfmake](https://github.com/bpampuch/pdfmake)