Hello,
I Want to Fill a pdf form. the pdf-document is from an external sources, so have no influence of the design.
I have extracted a PdfTextfield.
But Wenn I Set the Font and save the document it has no effect
wenn I step through the code after setting the Font to the PdfTextField it shows the right Values but in the generated document the text has a other Fontname/size.
What am I doing wrong?
(I've tried it with Version 1.3 pdfsharp and pdfsharp-wpf)
Code:
PdfDocument document = PdfReader.Open(@"D:\Testzeugs\Test_doc.pdf", PdfDocumentOpenMode.Modify);
PdfTextField currentField = (PdfTextField)(document.AcroForm.Fields["SOMEFIELD"]);
//This section makes the text visible
if (document.AcroForm.Elements.ContainsKey("/NeedAppearances"))
{
document.AcroForm.Elements["/NeedAppearances"] = new PdfBoolean(true);
}
else
{
document.AcroForm.Elements.Add("/NeedAppearances", new PdfBoolean(true));
}
//test
string caseName = "Hallo Welt";
PdfString caseNamePdfStr = new PdfString(caseName);
currentField.Font = new XFont("Arial", 8);
//set the value of this field
currentField.Value = caseNamePdfStr;
// Save the document...
document.Save(@"D:\Testzeugs\test.pdf");