Hi,
I used Aspose pdf for filling form fields. In a specific pdf attached:
input3.pdf (477.5 KB)
I can not set field values. It doesn’t give any error. Just when it reaches the line of code to set the value, it stops and doesn’t go further and even nothing happened. no error and nothing. just stucks there.
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(@"c:\temp\input3.pdf");
foreach (var field in doc.Form.Fields)
{
if (field is TextBoxField textField)
{
textField.Value = "abc"; <------- LINE of ISSUE
}
}
var output_pdf_path = @"c:\temp\test2.pdf";
doc.Save(output_pdf_path);
I used pdfSharp and seems it can set the value, I found the fields in this pdf has a setting to convert field value to uppercase. I guess this is the problem but I don’t know how to fix it with Aspose.
In pdf sharp it sets some form elements like this, without this code it doesn’t show the values but it never stucks, but Aspose stucks on the setting of value:
Setting of NeedAppearance in pdfSharp:
if (form.Elements.ContainsKey("/NeedAppearances"))
{
form.Elements["/NeedAppearances"] = new PdfSharp.Pdf.PdfBoolean(true);
}
else
{
form.Elements.Add("/NeedAppearances", new PdfSharp.Pdf.PdfBoolean(true));
}