-
-
Notifications
You must be signed in to change notification settings - Fork 696
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
Corrupted PDF #951
Comments
Here is the PDF file for reference so this could be easily reproduced. |
I have added a $500 bounty for anyone who can fix this. Not that I would consider this as fixed (for the bounty) only if this is fixed on PDF-Lib, not by changing the pdf file (eg saving/compressing it using other programs) |
I believe there is some non-critical error in the pdf file provided since I'm not able to run it through
I'm suspecting that the custom font is not properly embedded. For example, the following is using
FYI it is not part of the Are you in control of the generation of that particular PDF File? or do you just want to modify it? I've repaired your PDF file and provided in the following repo. |
HI @PhakornKiong. Good job at investigating. Since other pdf software are able to recover from this situation, I'd love to see a patch that'd make pdf-lib also recover from it. For example other pdf software are able to fallback to other fonts. Unfortunately I have a series of PDF's that are already generate. My intention is to be able to use them with pdf-lib. Thanks. |
@emilsedgh does this happen if you save the document with |
Yes. The same thing happens although the results look slightly different. |
Is this the corrupted PDF or the original PDF? |
This is the original one.
… On Sep 28, 2021, at 5:28 AM, Charles Timko ***@***.***> wrote:
test.pdf
Here is the PDF file for reference so this could be easily reproduced.
Is this the corrupted PDF or the original PDF?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
I also received this cryptic issue. Then I tested with the pdfLoadError tool. The individual lines didn't convince me as error handling. So I split the PDF document into the individual pages (https://www.ilovepdf.com/split_pdf) and, curiously, the split first page is now displayed correctly. So just by splitting the problem is gone. I hope @Hopding ding it helps you. |
Is the issue solved or not yet. |
@gpugems Looks like it's already fixed, @emilsedgh and @Hopding didn't bother updating the issue? As mentioned in #986, copying the pdf fixes the issue: import { PDFDocument } from 'pdf-lib';
import fs from "fs";
const buffer = fs.readFileSync("test.pdf");
const pdfDoc = await (await PDFDocument.load(buffer)).copy();
const pdfBytes = await pdfDoc.save();
fs.writeFileSync("output.pdf", pdfBytes); Although, I guess that's more of a workaround rather than an actual fix. |
Or not, there's a large size difference:
Copying the PDF also strips away this embedded js from test.pdf:
|
Hi.
This is an amazing library. Thanks a lot @Hopding. I know you've been inactive for a while but the quality of the code and the support you gave for this during your active time has been absolutely phenomenal. You don't see such fantastic support even for paid products. Good luck whatever you're up to.
My issue is this: I have this PDF file than looks like this:
But when I open/save it using pdf-lib, it will look like this:
Has anyone ever had a similar experience?
The text was updated successfully, but these errors were encountered: