Skip to content
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

Crash on get document.AcroForm #114

Open
oleg-finka opened this issue Feb 4, 2020 · 2 comments
Open

Crash on get document.AcroForm #114

oleg-finka opened this issue Feb 4, 2020 · 2 comments

Comments

@oleg-finka
Copy link

Can't open document.AcroForm

Expected Behavior

it should be null or have some meaningful object value

Actual Behavior

Crashes with an error

Unhandled Exception: System.InvalidCastException: Unable to cast object of type 'PdfSharp.Pdf.PdfNull' to type 'PdfSharp.Pdf.AcroForms.PdfAcroForm'.
   at PdfSharp.Pdf.Advanced.PdfCatalog.get_AcroForm()
   at PdfSharp.Pdf.PdfDocument.get_AcroForm()
   at IssueSubmission.Program.Main() in C:\Users\ofinka\Downloads\PDFsharp-IssueSubmission\IssueSubmission\Program.cs:line 25

It happens not with every pdf, but this one is critical for me.

Steps to Reproduce the Behavior

Just run IssueSubmission main project
PDFsharp-IssueSubmission.zip

@oleg-finka
Copy link
Author

Debugged a bit. Found that on parsing "/AcroForm" dictionary it can't find related object in irefTable - don't know why. That's why document.AcroForm == null.
PdfReader.cs:433 -> Parser.cs:187 -> Parser.cs:393 -> Parser.cs:486

@WyrmUK
Copy link

WyrmUK commented Jan 25, 2021

It might be because your Test.pdf contains Javascript. Whereas Adobe (and various other products/libraries) support that, I don't believe it is a standard PDF feature (like XFA isn't a standard PDF feature) so I wouldn't necessarily expect PDFSharp to support it. That said, there should be a graceful or more meaningful handling of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants