-
-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it async // return item as promise #129
Comments
If I understand well, you can probably write your own function to achieve that. Something like: import { PdfReader } from "pdfreader";
async function parsePdf(file) {
const items = [];
return new Promise((resolve, reject) => {
new PdfReader().parseFileItems("test/sample.pdf", (err, item) => {
if (err) reject(err);
else if (!item) resolve(items);
else if (item.text) items.push(item);
});
});
}
const items = await parsePdf("test.pdf"); Please let us know if that works for you. |
Thanks for the reply! :D Yes it is working but I had already found a way to return it as a Promise and make it async/await compatible. The point is that this would be a great feature if the package would return the final result as a Promise by default! |
See https://github.com/limulus/call-me-maybe for one potential solution. |
|
Describe the bug
We need to make the function async/await compatible. I need to return the result after the whole document is parsed.
To Reproduce
List the steps you followed and/or share your code to help us reproduce the bug
Expected behavior
Be able to await for the whole document to be parsed.
Screenshots, outputs or logs
If applicable, add screenshots, outputs or logs to help explain your problem.
Desktop (please complete the following information):
Ubuntu 20.04
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: