-
Notifications
You must be signed in to change notification settings - Fork 236
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
Exception thrown when setting trailer info element to null #432
Comments
Running into the exact same issue. Since my usage is automated extraction manual repairing of the file is not an option. Edit: Simple skipping setting the reference does not help fully for me. The document ends up with zero pages, although shows up fine with any other PDF viewer. Unfortunately I cannot share the document as it contains private data. |
It seems that the PDF is formatted incorrectly and Acrobat can fix it. |
File has been sent. Issue still happens in PdfSharpCore. The file can be read in PdfSharp, PdfPig, and others. Thank you. |
I have received the file. The reason for the issue is that the reference to object 312 is mentioned twice in the file. In PDFsharp (not in PdfSharpCore) I fixed this by removing the first entry when an identical second entry occurred. See original source code from PDFsharp 6.1 below. In PdfSharpCore just call
|
When opening specific documents I get an exception:
{"Value cannot be null. (Parameter 'value')"}
Unfortunately, these documents come from an external source, and all of them have this issue. As a work around I have to manually open the pdf in acrobat or something and then save it (without doing anything). This seems to add something to the "INFO" where it does not throw an exception. I would like to be able to still open the file in code.
Stack trace:
This happens in this code when trying to set the info element to null:
https://github.com/ststeiger/PdfSharpCore/blob/cdf089b6c4d6b379aead95f463911dd009ae194e/PdfSharpCore/Pdf.Advanced/PdfTrailer.cs#L191C13-L198C14
Expected behavior:
not to crash - allow setting the value to null or skip setting the element if the value is null
The text was updated successfully, but these errors were encountered: