PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Oct 01, 2022 10:48 am

All times are UTC

Forum rules

Please read this before posting on this forum: Forum Rules

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Fri May 14, 2021 6:15 am 

Joined: Wed May 12, 2021 10:04 pm
Posts: 1
i am trying to write the following PDF template using PDFsharp ,

below is my Sample code i am using ,

using (var fs = new FileStream(ReportPath + newfile, FileMode.Create))
// Get the template and copy it to another document
PdfSharp.Pdf.PdfDocument myTemplate = PdfSharp.Pdf.IO.PdfReader.Open(pdfTemplateMod22, PdfSharp.Pdf.IO.PdfDocumentOpenMode.Modify);
PdfSharp.Pdf.PdfDocument newDoc = (PdfSharp.Pdf.PdfDocument)myTemplate.Clone();

var acroFields = newDoc.AcroForm.Fields; // i am getting a null pointer exception here

//Ensure the new values are displayed
if (newDoc.AcroForm.Elements.ContainsKey("/NeedAppearances"))
newDoc.AcroForm.Elements["/NeedAppearances"] = new PdfSharp.Pdf.PdfBoolean(true);
newDoc.AcroForm.Elements.Add("/NeedAppearances", new PdfSharp.Pdf.PdfBoolean(true));


if (newDoc.AcroForm != null)
newDoc.Flatten(); // NOTE: doc.AcroForm is null after flattening ! and the pdf is not editable

url = "../relatorios/temporarios/" + newfile;

I am Getting AcroForm as Null.
Can any i have idea why my AcroNorm fields are not being Read by PDFsharp??

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: Google [Bot] and 3 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