0
votes

When filling a pdf document with pdfsharp (pdfsharpcore), the filled form doesn't show the values in the acrobat reader unless the fields are clicked on.

2

2 Answers

0
votes

In order to make the values visible, I've inserted.

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

and it works.

0
votes

I was dealing with same problem. Text appears only when I clicked to field.

var document = PdfReader.Open("pristupy.pdf", PdfDocumentOpenMode.Modify);
document.AcroForm.Fields[0].Value = new PdfString(user.LastName + " " + user.FirstName);
document.AcroForm.Fields[1].Value = new PdfString(unit.Name);
document.AcroForm.Fields[2].Value = new PdfString(system.Name);
document.AcroForm.Fields[3].Value = new PdfString(accessApplication.AppliedDate.ToShortDateString());
document.AcroForm.Fields[4].Value = new PdfString(roleAddString);
document.AcroForm.Fields[5].Value = new PdfString(roleRemoveString);

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

Now its working correctly! (using PdfSHARP)