Skip to content

Instantly share code, notes, and snippets.

@niksudan
Created July 11, 2017 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niksudan/6db2d8c4e3226136e5f5caa73d6ac895 to your computer and use it in GitHub Desktop.
Save niksudan/6db2d8c4e3226136e5f5caa73d6ac895 to your computer and use it in GitHub Desktop.
Convert a PDF document to separate images
const PDFImage = require('pdf-image').PDFImage;
const pdfImage = new PDFImage('./input/document.pdf');
const convert = (page) => {
return pdfImage.convertPage(page);
}
let canConvert = true;
let currentPage = 0;
setInterval(() => {
if (canConvert) {
canConvert = false;
convert(currentPage).then((path) => {
console.log(path);
currentPage++;
canConvert = true;
});
}
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment