PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 11:58 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sun Jan 22, 2017 8:45 pm 
Offline

Joined: Mon Jan 16, 2017 8:06 pm
Posts: 5
Location: Borås, Sweden
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 23, 2017 8:47 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
I cannot replicate the issue. A VS solution that includes the PDF file would be nice.

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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 23, 2017 12:13 pm 
Offline

Joined: Tue Jan 13, 2009 3:43 pm
Posts: 2
Maybe it's a typo ["txtProjNamn"] and ["txtProjName"] iscorrect


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 23, 2017 1:41 pm 
Offline

Joined: Mon Jan 16, 2017 8:06 pm
Posts: 5
Location: Borås, Sweden
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 23, 2017 5:42 pm 
Offline

Joined: Mon Jan 16, 2017 8:06 pm
Posts: 5
Location: Borås, Sweden
Ok, then I have created a small POE VS2015 Solution, Where do I mail it.
The ZIP-file is 1,6 MB.


Top
 Profile  
Reply with quote  
PostPosted: Thu May 25, 2017 9:23 pm 
Offline

Joined: Thu May 25, 2017 9:19 pm
Posts: 1
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);


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 142 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group