-
Notifications
You must be signed in to change notification settings - Fork 133
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
System.AggregateException: 'Invalid object ID.' when trying to open some pdfs #73
Comments
The PDF has some interesting properties... There is a stream-object with a This is an issue because of the way the library loads the objects stored in a PDF:
The exception is thrown in phase 1.: While the PDF-spec states that objects representing the That said, it's the first time i encountered a PDF doing this and I've seen a lot of PDFs over the last >10 years ! Because it does not seem to be common practice to store objects like that, a fix handling this specific case should be straightforward. @ThomasHoevel I already have code doing this, tested successfully with the attached PDF. On the long run, the library should be adapted to read objects in a way that can locate referenced objects regardless of their location, i.e. whether they are stored on the file-level or in object-streams. |
@packdat Thanks for your feedback and analysis. |
Hi @packdat, thanks for your help. I have had trouble with similar files that are scanned, right now I don't have any example of the PDFs that are converted from .dwg files that throw me errors when trying to open with PDFSharp too. Is there any tip you can give me please to relay to the people who are scanning these documents that way we can avoid this problem and have a clean and safe PDF to use with PDFSharp? |
Hi @andresdbv The metadata of the PDF states: If all they do is convert images obtained from a scanner to PDF, you could write your own little tool based of PDFsharp that does the conversion and let them use that. |
Hi, I've just downloaded recent ISO spec 2 days ago and I'm slowly reading it... I'm completely new to this so I may be mistaking but I believe you shouldn't throw in this case. In
So the And about your point(step) 2 - I believe the PDF was specifically designed so there is no need to load whole thing into memory. In version 1.0 at https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/pdfreference1.0.pdf it's mentioned several times that the format should allow reading only single page (from a big document) and should be suitable for devices with low memory... Does this make sense? Again, I didn't even go through half of the specs, so sorry if I made some confusion, but I'm also curious about this. |
I'm not thowing anything, the PR attempts to avoid that.
Correct.
Are we talking about PDF in general or about the specific PDF mentioned here ?
That's exactly, what #85 attempts to do.
In a perfect world, that would be the case.
No worries. PDF (and "flavors" thereof) are a sometimes confusing matter. |
I have been using for years 1.50.5147.0 to open pdfs and add some text to them. The thing is that it has trouble opening some files with
PdfReader.Open(pathFilePDF, PdfDocumentOpenMode.Modify)
(I've read about this and that I should save them again - I print them to pdf again with chrome and it works). As this is a service in the backend it gives us a lot of trouble. Some of the problematic pdfs are scans of physical documents and others are pdf saved from Autocad.Our solution uses .net framework 4.72, so when I read that 6.1.0-preview-1 could be used in my project I thought to give it a try and set up a little project to see if it could handle the files that give us problems, to no avail.
So to check if I was doing something wrong I fired up a project in net.6 with 6.0.0 version of the library and it worked.
Expected Behavior
It should open the pdf attached in the Issue Template Project (File.pdf)
Actual Behavior
It gives me this error:
System.AggregateException: 'Invalid object ID.'
Steps to Reproduce the Behavior
Here is the template, the code is just to try to open the pdf file I attached within the solution
Issue.zip
(if you can at least help me to know what its wrong with the pdf would be awesome)
The text was updated successfully, but these errors were encountered: