Created
July 11, 2017 10:13
-
-
Save niksudan/6db2d8c4e3226136e5f5caa73d6ac895 to your computer and use it in GitHub Desktop.
Convert a PDF document to separate images
This file contains hidden or 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 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