lundegaard / gatsby-plugin-pdf

Gatsby plugin that is able generate PDFs out of your gatsby web pages
MIT License
9 stars 8 forks source link
gatsby gatsby-plugin pdfs puppetter react

gatsby-plugin-pdf

by Lundegaard

🖨 ⚙ 🔌

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.

Github MIT License Downloads Version

Installation

Setup your gatsby project and add gatsby-plugin-pdf as your dependency

yarn add gatsby-plugin-pdf
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.

module.exports = {
    ...
    plugins: [
        ...
        {
            resolve: 'gatsby-plugin-pdf',
            options: {
                paths: ['/', '/page1', '/page2'],
                outputPath: '/public/exports',
            },
        },
    ],
};

Example 2: Exporting all pages with additional inline style.

module.exports = {
    ...
    plugins: [
        ...
        {
            resolve: 'gatsby-plugin-pdf',
            options: {
                allPages: true,
                styleTagOptions: {
                    content: 'header{display:none;} footer{display:none;} .cookie-bar{display:none;}'
                }
            },
        },
    ],
};

Configuration options

Contribution

We are open to any ideas and suggestions! Feel free to make PR!

See contribution guide for guidelines.

See our related projects

© 2020 Lundegaard a.s.