Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/bkniffler/react-pdfmake
- Owner: bkniffler
- License: mit
- Created: 2018-10-25T11:58:09.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-12-09T01:47:55.000Z (about 3 years ago)
- Last Synced: 2023-08-05T15:09:46.040Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 468 KB
- Stars: 12
- Watchers: 3
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## 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)