PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Mar 19, 2024 4:28 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 
Offline

Joined: Wed May 12, 2021 10:04 pm
Posts: 1
i am trying to write the following PDF template using PDFsharp ,
https://drive.google.com/file/d/18OMWprC3u-sSTq87yZ6jUrrRqQt3hcW4/view?usp=sharing

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);
else
newDoc.AcroForm.Elements.Add("/NeedAppearances", new PdfSharp.Pdf.PdfBoolean(true));

FuncoesAuxiliaresPdf.SetVarsModelo22(acroFields);

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

newDoc.Save(fs);
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??


Top
 Profile  
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 30 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