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

PDFSharp-WPF 1.50.4000-beta3b throws exception
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3533
Page 1 of 1

Author:  TomasL [ Sun Jan 22, 2017 8:45 pm ]
Post subject:  PDFSharp-WPF 1.50.4000-beta3b throws exception

Code that worked in the stable 1.32.3057 now throws "System.NullReferenceException' occurred in PdfSharp-wpf.dll" "Additional information: Object reference not set to an instance of an object."
I am using the following code:
Code:
PdfDocument document = PdfReader.Open(toPath, PdfDocumentOpenMode.Modify);
            if (document.AcroForm.Elements.ContainsKey("/NeedAppearances") == false)
            {
                document.AcroForm.Elements.Add("/NeedAppearances", new PdfBoolean(true));
            }
            else
            {
                document.AcroForm.Elements["/NeedAppearances"] = new PdfBoolean(true);
            }
PdfTextField currField = (PdfTextField)document.AcroForm.Fields["txtProjNamn"];
currField.Text = projData.projName;

It is the last row above that throws the exception.
The document with all fields is created in Acrobat 8 Pro.
I moved over to the latest beta today, since I need to use streams for images, after that it does not work anymore.
projData.projName is a public static string.

Author:  Thomas Hoevel [ Mon Jan 23, 2017 8:47 am ]
Post subject:  Re: PDFSharp-WPF 1.50.4000-beta3b throws exception

I cannot replicate the issue. A VS solution that includes the PDF file would be nice.

See also:
viewtopic.php?p=2094#p2094

Author:  Fish [ Mon Jan 23, 2017 12:13 pm ]
Post subject:  Re: PDFSharp-WPF 1.50.4000-beta3b throws exception

Maybe it's a typo ["txtProjNamn"] and ["txtProjName"] iscorrect

Author:  TomasL [ Mon Jan 23, 2017 1:41 pm ]
Post subject:  Re: PDFSharp-WPF 1.50.4000-beta3b throws exception

Nope, not a typo, I am using a mix of Swedish and English for some reason.

Anyway, tried to upload the PDF here, but its to big. (approx 700kB)
Anyway, you can find the form at www.tlec.se/Utskriftsform.pdf

Ill try to do a small mini project as well.

Author:  TomasL [ Mon Jan 23, 2017 5:42 pm ]
Post subject:  Re: PDFSharp-WPF 1.50.4000-beta3b throws exception

Ok, then I have created a small POE VS2015 Solution, Where do I mail it.
The ZIP-file is 1,6 MB.

Author:  trevorw [ Thu May 25, 2017 9:23 pm ]
Post subject:  Re: PDFSharp-WPF 1.50.4000-beta3b throws exception

I saw in another post, PdfTextField has changed in 1.5 beta

currField.Text = projData.projName;

now needs to be

currField.Value = new PdfString(projData.projName);

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