pdf-stringfy
v1.0.1
Published
js module to extract texts from PDFs.
Downloads
8
Maintainers
Readme
pdf-stringfy
js module to extract texts from PDFs.
Installation
npm install pdf-stringfy
Basic Usage - Get all pages
const fs = require('fs');
const PdfStringfy = require('pdf-stringfy');
let dataBuffer = fs.readFileSync('path-to-pdf');
PdfStringfy(dataBuffer).then(function(data) {
console.log(data.numpages);
console.log(data.numrender);
console.log(data.info);
console.log(data.metadata);
console.log(data.version);
console.log(data.text);
});
Get only one page 35
const fs = require('fs');
const PdfStringfy = require('pdf-stringfy');
let dataBuffer = fs.readFileSync('path-to-pdf');
let options = {
onePageOnly: 35,
};
PdfStringfy(dataBuffer, options).then(function(data) {
console.log(data.numpages);
console.log(data.numrender);
console.log(data.info);
console.log(data.metadata);
console.log(data.version);
console.log(data.text);
});
Exception Handling
const fs = require('fs');
const PdfStringfy = require('pdf-stringfy');
let dataBuffer = fs.readFileSync('path-to-pdf');
PdfStringfy(dataBuffer).then(function(data) {
console.log(data.text);
})
.catch(function(error){
console.error("error", error.message);
})
Example
npm run example
ornode example/pdf-stringfy-example.js
- Check example code. When you run the example you should have an output.txt with parsed input.pdf file.
Test
mocha
ornpm test
- Check test folder.
License
MIT licensed and all it's dependencies are MIT or BSD licensed.