We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Number formatting getting lost in pdf file while setting the value using aspose

I am trying to set value to a form field using aspose.pdf for .net. There is a number formatting being provided in the pdf template which is not applied after i set the value.

below is the sample code i am using
string fileName = “FormTemplate.pdf”;
string filePath = Path.Combine(GetCurrentDirectory(), “GeneratedForms”, fileName);
Document pdfDocument = new Document(filePath);
TextBoxField field = pdfDocument.Form[“fieldName”] as TextBoxField;
field.Value = “-372002.7100000”;

I even tried adding below code to make it work but not getting the expected output
field.Actions.OnModifyCharacter = new JavascriptAction(“AFNumber_Keystroke(0, 0, 2, 0, ‘’, true)”);
field.Actions.OnFormat = new JavascriptAction(“AFNumber_Format(0, 0, 2, 0, ‘’, true)”);

the expected output should be (372003).

below is the pdf screen shot for your reference
image.png (9.3 KB)
image.png (131.3 KB)


Thank you for contacting support.

Would you please share source and generated file so that we may try to reproduce and investigate it in our environment. Before sharing requested data, please ensure using Aspose.PDF for .NET 19.4.

yes i am using the latest version of the aspose.pdf for .net
i have attached source file and output file for your reference. in the output file you will find for a form field the value being displayed as -,370,003 and the value passed was -370002.7100000. the desired output should be (370,003). braces for negative number, zero decimal digits and 1000 separator.
The issue is mainly occurring if the passed value is negative, the parenthesis are not getting applied and even the thousand separator is not proper.

FormTemplate.pdf (111.0 KB)
Outputfile.pdf (108.9 KB)


Thank you for sharing requested data.

We have been able to reproduce the issue in our environment. A ticket with ID PDFNET-46341 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.