commonjs #136
Unanswered
tobiasgrossmann
asked this question in
Q&A
commonjs
#136
Replies: 1 comment
-
Here's how to import and use import('pdfreader').then(({ PdfReader }) => {
new PdfReader().parseFileItems(
'file.pdf',
(err, item) => {
if (err) console.error('error:', err);
else if (!item) console.warn('end of file');
else if (item.text) console.log(item.text);
},
);
}); As explained in How to run ES packages in CommonJS modules, the trick is that the call to |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there a way to import the pdfreader into a commonjs solution?
This would had been my approach: let PdfReader = import("pdfreader"); but PdfReader is not a constructor.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions