Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lundegaard/gatsby-plugin-pdf
Gatsby plugin that is able generate PDFs out of your gatsby web pages
https://github.com/lundegaard/gatsby-plugin-pdf
gatsby gatsby-plugin pdfs puppetter react
Last synced: 29 days ago
JSON representation
Gatsby plugin that is able generate PDFs out of your gatsby web pages
- Host: GitHub
- URL: https://github.com/lundegaard/gatsby-plugin-pdf
- Owner: lundegaard
- License: mit
- Created: 2020-11-20T12:07:14.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-11-17T02:36:12.000Z (almost 2 years ago)
- Last Synced: 2024-09-29T16:13:13.921Z (about 1 month ago)
- Topics: gatsby, gatsby-plugin, pdfs, puppetter, react
- Language: JavaScript
- Homepage:
- Size: 51.8 KB
- Stars: 9
- Watchers: 6
- Forks: 8
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
gatsby-plugin-pdf
🖨 ⚙ 🔌
Gatsby plugin that is able generate PDFs out of your gatsby web pages
With the plugin you are able to generate PDFs out of your gatsby web pages. PDFs are created during build time and so you are able to store them into a folder from which you can serve them later on the web.
## Installation
Setup your [gatsby project](https://www.gatsbyjs.com/) and add `gatsby-plugin-pdf` as your dependency
```bash
yarn add gatsby-plugin-pdf
``````bash
npm install gatsby-plugin-pdf
```## Usage
In your gatsby project add a plugin definition into your `gatsby-plugin.js` config.
**Example 1**: Exporting pages /page1, /page2 and a root index.html denoted by single '/' in the config below.
```js
module.exports = {
...
plugins: [
...
{
resolve: 'gatsby-plugin-pdf',
options: {
paths: ['/', '/page1', '/page2'],
outputPath: '/public/exports',
},
},
],
};```
**Example 2**: Exporting all pages with additional inline style.
```js
module.exports = {
...
plugins: [
...
{
resolve: 'gatsby-plugin-pdf',
options: {
allPages: true,
styleTagOptions: {
content: 'header{display:none;} footer{display:none;} .cookie-bar{display:none;}'
}
},
},
],
};```
## Configuration options
- `allPages` <[boolean]> When true all pages will be converted to PDF files. Defaults to false. Either `allPages` or `paths` property must be specified.
- `styleTagOptions` <[Object]> Optional configuration. See addStyleTag puppeteer options: https://github.com/puppeteer/puppeteer/blob/v5.5.0/docs/api.md#pageaddstyletagoptions.
- `url` <[string]> URL of the `` tag.
- `path` <[string]> Path to the CSS file to be injected into frame. If path is a relative path, then it is resolved relative to current working directory.
- `content` <[string]> Raw CSS content to be injected into frame.
- `filePrefix` <[string]> Optional prefix for exported PDF file.
- `outputPath` <[string]> Optional path where to store generated PDFs. Relative to current project dir. Defaults to `/public/exports`.
- `paths` <[Array]<[string]>> Array of page paths to convert to PDF. Path have to start with a leading /. You can pass nested paths like '/path/subpath'. For the root path use just single '/'. Either `allPages` or `paths` property must be specified.
- `pdfOptions` <[Object]> Optional configuration. See pdf puppeteer options: https://github.com/puppeteer/puppeteer/blob/v5.5.0/docs/api.md#pagepdfoptions.## Contribution
We are open to any ideas and suggestions! Feel free to make PR!
See [contribution guide](https://github.com/lundegaard/gatsby-plugin-pdf/blob/main/CONTRIBUTING.md) for guidelines.
## See our related projects
- [@redux-tools](https://github.com/lundegaard/redux-tools) - Modular Redux is possible!
- [react-union](https://github.com/lundegaard/react-union) - Intergrate React apps into various CMSs seamlessly.
- [validarium](https://github.com/lundegaard/validarium) - Validations done right.
- [apium](https://github.com/lundegaard/apium) - Redux middleware for event-driven HTTP requests with async/await support.© 2020 Lundegaard a.s.