Welcome folks today in this blog post we will be using the pdf-export-images
library to export all the pages
of the pdf document and save it as images
in terminal. All the full source code of the application is shown below.
Get Started
In order to get started you need to make a new node.js
project using the below command
npm init -y
npm i pdf-export-images
And now you will see the below directory
structure of the node.js
app as shown below
And now we need to go inside the package.json
file and add the type
property inside the package.json
file as shown below
package.json
And now you need to make a new file
called index.js and copy paste the following code
index.js
1 2 3 4 |
import { exportImages } from 'pdf-export-images' exportImages('pdf.pdf', 'uploads') .then(images => console.log('Exported', images.length, 'images')) .catch(console.error) |
And now inside the above code we are importing the pdf-export-images
library and then we are providing the uploads
folder to store the exported
images and then we are also providing the input
pdf file called pdf.pdf
.