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

Changing Fonts on TextFields...
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3545
Page 1 of 1

Author:  blewis1975 [ Fri Feb 24, 2017 4:11 pm ]
Post subject:  Changing Fonts on TextFields...

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());

Author:  iksde [ Tue Apr 24, 2018 10:07 am ]
Post subject:  Re: Changing Fonts on TextFields...

Same crap right here. I am using AcroField PdfTextField, and I simply cant set /DA

I've tried setting it through elements, through font property, it simply does not work.

Anybody has anything ?

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