使用 pdfsharp 填充 pdf 文档时,除非单击字段,否则填充的表单不会显示值

when filling a pdf document with pdfsharp, the filled form doesn't show the values unless the fields are clicked on

使用 pdfsharp (pdfsharpcore) 填充 pdf 文档时,填充的表格不会在 acrobat reader 中显示值,除非单击字段。

为了让值可见,我插入了。

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

而且有效。

我遇到了同样的问题。文本仅在我单击字段时出现。

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

现在可以正常使用了! (使用 PdfSHARP)