ststeiger / PdfSharpCore

Port of the PdfSharp library to .NET Core - largely removed GDI+ (only missing GetFontData - which can be replaced with freetype2)
Other
1.07k stars 239 forks source link

Viewing filled in form fields not working in Safari #335

Open jsa061 opened 1 year ago

jsa061 commented 1 year ago

If you have a form, with a form field, and use Pdf Sharp Core to fill inn the form field, it will not show when you open the PDF in safari.

Steps to reproduce

Create a form with a form field. Adobe acrobat => tools => prepare form.

pdf-form

Fill in form field with Pdf Sharp Core ( .net 7)

        var pdf = PdfReader.Open("C:\\PdfSharpCore\\FullNameForm.pdf", PdfDocumentOpenMode.Modify);
        var form = pdf.AcroForm;

        form.Elements.Add("/NeedAppearances", new PdfBoolean(true));

        var pdfTextFieldFullName = (PdfTextField)(form.Fields["FullName"]);

        pdfTextFieldFullName.Value = new PdfString("Justin Sand", PdfStringEncoding.PDFDocEncoding);
        pdfTextFieldFullName.ReadOnly = true;
        pdf.Save("c:\\PdfSharpCore\\FullName.pdf");
        pdf.Close();

PDF in Safari

image

Pdf in Chrome:

image

maattss commented 1 year ago

+1