npm i pdf-extractor
index.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
const PdfExtractor = require('pdf-extractor').PdfExtractor; let outputDir = 'output', pdfExtractor = new PdfExtractor(outputDir, { viewportScale: (width, height) => { //dynamic zoom based on rendering a page to a fixed page size if (width > height) { //landscape: 1100px wide return 1100 / width; } //portrait: 800px wide return 800 / width; }, }); pdfExtractor.parse('sample.pdf').then(function () { console.log('# End of Document'); }).catch(function (err) { console.error('Error: ' + err); }); |