-
Notifications
You must be signed in to change notification settings - Fork 135
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 when accessing PdfDocument.AcroForm.Fields #213
Comments
Please consider using the Issue Submission Template: |
I added steps needed to reproduce the NullReferenceException, hope it helps. |
When i added the attached document to my test-files and run my usual tests on it, I noticed this message in PDFsharp's log-output:
So there you have your document, as requested ! 😉 I did some digging and found that object
As the file is read from back to front, the AcroForm-reference is read first. I would say, this issue is two-fold:
|
I tried to load the attached file and iterate over pdf.AcroForm.Fields. At first I encountered an error:
No appropriate constructor found for type: PdfAcroFieldCollection at PdfSharp.Pdf.PdfDictionary.DictionaryElements.CreateArray(Type type, PdfArray oldArray)
So I added a constructor it was looking for:
public PdfAcroFieldCollection(PdfDocument document): base(document){ }
Error "solved", but next one appeared:
'Object already in table.' at PdfSharp.Pdf.Advanced.PdfCrossReferenceTable.Add(PdfObject value)
I tried to change Add to ObjectTable[value.ObjectID]=value.ReferenceNotNull;, then there was no exception, but pdf.AcroForm.Fields were empty.
21a352e0-dd03-4855-a1e5-82fb3690493c.pdf
Steps to reproduce:
dotnet new console -n PdfSharpBug
cd PdfSharpBug
dotnet add package PdfSharp
code .
dotnet run
Observed result:
$(String[] args) in C:\git\PdfSharpBug\Program.cs:line 8Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at PdfSharp.Pdf.PdfDictionary.DictionaryElements.CreateArray(Type type, PdfArray oldArray)
at PdfSharp.Pdf.PdfDictionary.DictionaryElements.GetValue(String key, VCF options)
at PdfSharp.Pdf.AcroForms.PdfAcroForm.get_Fields()
at Program.
The text was updated successfully, but these errors were encountered: