PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Getting NullReferenceException when assigning values to form
https://forum.pdfsharp.net/viewtopic.php?f=2&t=4228
Page 1 of 1

Author:  KenBobPDX [ Mon Feb 01, 2021 11:15 pm ]
Post subject:  Getting NullReferenceException when assigning values to form

I'm getting a system.NullReferenceException when I'm assigning a text value to a PDF form that I created in Acrobat Pro DC. The stack trace indicates it's happening deep in the PdfSharp.Pdf.AcroForms.PdfTextField.RenderAppearance() code. Here's the stack trace:

at PdfSharp.Pdf.AcroForms.PdfTextField.RenderAppearance()
at PdfSharp.Pdf.AcroForms.PdfTextField.set_Text(String value)
at <my code that assigns the text value>

This line is causing the exception: ((PdfTextField)field).Text = origValue;

I'm new to PdfSharp, so I'm guessing I must have missed something basic.

Can anyone lend some insight? What do I need to do to stop throwing this exception?

Oh, by the way, I get the same error when I run the sample code for filling out form fields.

If I wrap the assignments in a try/catch block and ignore the exceptions, the form is filled out correctly. I can open it in Adobe Acrobat and see all the data so it seems like a bug in PdfSharp.

Thanks in advance,
Ken

Author:  rosin [ Fri Aug 26, 2022 12:34 pm ]
Post subject:  Re: Getting NullReferenceException when assigning values to

I also have the same problem.Has anyone been able to solve this problem?
Thanks everyone for the help :) .

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/