Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise(function (resolve, reject) {
try {
var doc = new PopplerDocument(path);
if (doc.pageCount < 1) {
return reject(new Error('Invalid PDF'));
}
var result = { type: 'pdf', pages: [] };
for (var i = 1; i <= doc.pageCount; i++) {
var page = doc.getPage(i);
result.pages.push({
width: page.width,
height: page.height
});
}
resolve(result);