PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu May 25, 2017 2:34 pm

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 Feb 24, 2017 4:11 pm 
Offline

Joined: Mon Feb 20, 2017 8:50 pm
Posts: 1
Hello,

I have a PDF document with a number of text fields. In the appearance tab of each text field, the font is set to Times New Roman. However, when update the field values in code and save the PDF, the text values are not in Times New Roman. I've search the forums and have tried all the recommendations. I've set the /NeedAppearances and /DA values to true. I've tried to set the Elements value on the field itself and nothing has worked. Does anybody have any ideas? A code example is below:


string invoiceTemplate = @"D:\invoicetemplate.pdf";
PdfDocument document = PdfReader.Open(invoiceTemplate, PdfDocumentOpenMode.Modify);

if (!document.AcroForm.Elements.ContainsKey("/NeedAppearances"))
document.AcroForm.Elements.Add("/NeedAppearances", new PdfBoolean(true));
else
document.AcroForm.Elements["/NeedAppearances"] = new PdfBoolean(true);

if (!document.AcroForm.Elements.ContainsKey("/DA"))
document.AcroForm.Elements.Add("/DA", new PdfBoolean(true));
else
document.AcroForm.Elements["/DA"] = new PdfBoolean(true);

document.AcroForm.Elements.SetString(PdfAcroField.Keys.DA, "Times New Roman 20 Tf 0 g");

document.AcroForm.Fields["OrderDate"].Value = new PdfString(order.OrderDate.ToLongDateString());


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: Bing [Bot] and 6 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:  
Powered by phpBB® Forum Software © phpBB Group