24 lines
604 B
JavaScript
24 lines
604 B
JavaScript
const fs = require('fs');
|
|
const pdf = require('pdf-parse');
|
|
|
|
console.log('Type of pdf:', typeof pdf);
|
|
console.log('pdf export:', pdf);
|
|
|
|
let dataBuffer = fs.readFileSync('Informationen.pdf');
|
|
|
|
try {
|
|
if (typeof pdf === 'function') {
|
|
pdf(dataBuffer).then(function(data) {
|
|
console.log(data.text);
|
|
});
|
|
} else if (pdf.default && typeof pdf.default === 'function') {
|
|
pdf.default(dataBuffer).then(function(data) {
|
|
console.log(data.text);
|
|
});
|
|
} else {
|
|
console.log('Cannot find pdf function');
|
|
}
|
|
} catch (e) {
|
|
console.error(e);
|
|
}
|