Find the number of PDF pages using Node (on Windows)

I have done a lot of research (in my opinion, not enough?), And I'm trying to find an easy-to-use library to find the number of pages in PDF format using Node.js. The library must be usable on Windows.

Does anyone know how best to approach this? In the worst case, I was thinking of doing something with PhantomJS and the PDF.js.

Thanks for any help!

+5
source share
1 answer

Since it is built on pdf.js, pdf2json , it should work in windows.

I managed to find the number of pages of the test document as follows:

var PDFParser = require('pdf2json'); var pdfParser = new PDFParser(); pdfParser.on('pdfParser_dataReady', function(data) { var doc = data.PDFJS && data.PDFJS.pdfDocument && data.PDFJS.pdfDocument.numPages; console.log('Number of pages:', doc); }); // pdfParser.on('pdfParser_dataError', _.bind(_onPFBinDataError, self)); pdfParser.loadPDF('test.pdf'); 
+5
source

All Articles