Last active
November 23, 2021 03:08
-
-
Save harryawk/98ec398facad8740eeaa26bb210a109b to your computer and use it in GitHub Desktop.
Convert PDF to Image on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const app = (file) => { | |
const path = require('path'); | |
const pdf = require('pdf-poppler'); | |
let opts = { | |
format: 'jpeg', | |
out_dir: path.dirname(file), | |
out_prefix: path.basename(file, path.extname(file)), | |
page: null | |
}; | |
pdf.convert(file, opts) | |
.then(res => { | |
console.log('Successfully converted'); | |
}) | |
.catch(error => { | |
console.error(error); | |
}); | |
} | |
app('C:\\tmp\\convertme.pdf'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pre-requisite
Steps to run the script
npm init
, press enter all the way to the endnpm i -S pdf-poppler
node app.js