gatsby-transformer-pdf

4.13.1 • Public • Published

gatsby-transformer-pdf

Use pdf2Json to extract textual content of pdf files.

Install

npm install gatsby-transformer-pdf

You also need to have gatsby-source-filesystem installed and configured so it points to your files.

How to use

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `data`,
        path: `${__dirname}/src/data/`,
      },
    },
    `gatsby-transformer-pdf`,
  ],
}

Then you'll be able to query the textual content of your pdf files like:

{
  allPdf {
    edges {
      node {
        content
      }
    }
  }
}

Which would return:

{
  "data": {
    "allPdf": {
      "edges": [
        {
          "node": {
            "content": "1 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vel purus id tortor \r\neleifend vulputate. Integer interdum ultricies ligula, nec mattis lorem viverra ac. \r\n"
          }
        }
      ]
    }
  }
}

Package Sidebar

Install

npm i gatsby-transformer-pdf

Weekly Downloads

563

Version

4.13.1

License

MIT

Unpacked Size

37.1 kB

Total Files

7

Last publish

Collaborators

  • kathmbeck
  • pieh
  • tylerbarnes
  • fk
  • daniellewgatsby
  • kylemathews
  • freiksenet
  • dschau
  • monastic.panic
  • wardpeet
  • m-allanson
  • sidharthachatterjee
  • moocar