I'm creating a script which reads data from pdf in node, I'm using pdf_text_extract
, and I'm trying to return the data with Bluebird.
Types.js:
var pdf = require('pdf');
var Types = {
read: function(file, extension) {
pdf.extract(file, function(error, data) {
console.log(data);
});
}
};
module.exports = Types;
The data is a [Function], this is clearly wrong.
Pdf.js:
var Promise = require('bluebird');
var pdf_text_extract = require('pdf-text-extract');
var Pdf = {
extract: function(file, cb) {
return new Promise(function(resolve, reject) {
if (reject) {
console.log(reject);
}
pdf_text_extract(file, function(error, data) {
if (error) {
console.log(error);
}
resolve(data);
});
});
}
};
module.exports = Pdf;
I'm trying to access the data in other archive, which is calling the Types.js.