-
Notifications
You must be signed in to change notification settings - Fork 142
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
Error: Invalid stream: endstream not found #285
Comments
Hi, thanks for the report and for providing an actual example PDF!
I agree, this must be avoided. It looks like I am able to successfully catch the error in the following snippet: const fs = require("fs");
const pdf = require("./");
async function main() {
try {
const doc = new pdf.Document({
font: require("./font/Helvetica"),
padding: 0,
});
doc.pipe(fs.createWriteStream("output.pdf"));
const src = await fs.promises.readFile(
"891a951c3d0bbf66d6fb851500629cf78a73ab88_Facture_FSECU83196.pdf"
);
const ext = new pdf.ExternalDocument(src);
doc.addPagesOf(ext);
doc.text("Test", { borderBottomWidth: 1, borderBottomColor: 0x000000 });
await doc.end();
} catch (err) {
console.log("Caught error:");
console.error(err);
}
}
main(); It prints out:
Are you making sure to either use the try/catch inside of an To the error itself.
I am generally open to that, though depends a bit on how involved the workaround is. In this case, I've created a potential workaround #286. However, while the error is gone, the PDF in question just produces white pages. Looks like there is something else wrong, but tracking that down is unfortunately beyond the time I am willing to invest in it, sorry. The question now is, would the workaround work for other cases, or does it always produce white pages. Because if it's the latter, I'd rather keep the error. |
Hi!
After some research it seams this is a known issue due to pdf generators not following pdf specifications close enough.
Unfortunately we still have to deal with it... Any chance we could bake in a fix in the lib or find a workaround?
The issue is also that this error makes our application crash, it's not caught even if inside a try / catch block for some reason.
You can find a pdf that allows to reproduce the issue here.
The text was updated successfully, but these errors were encountered: