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

Free Support Forum - aspose.com

How to set field's font size

Dear experts,

I have an existing pdf document, and one of its fields is quite large. So when it is programmatically populated with the text, the font size is huge. I was not able to find an example of the code to change this. Could you please help?

Here is my code:
Document pdfDocument = new Document(Path.Combine(Server.MapPath(@"~/Templates/" + pdfFileName)));

((TextBoxField)pdfDocument.Form["_myField"]).Value = myValue;



Thanks for contacting support.

You may please set font size of a TextBoxField using following code snippet:

TextBoxField tbf = ((TextBoxField)doc.Form["_myField"]);
tbf.DefaultAppearance.FontSize = 20; 

In case above code does not help, please share your sample PDF document with us, so that we can test the scenario in our environment and address it accordingly.

Good Morning,

Thank you for your answer. This code doesn’t help. Please see the attached file.S-0121 Stock PAA - ORIGINAL.pdf (43.7 KB)

The problematic field is “_freight_terms” textbox.


Thanks for getting back to us.

We have tested the scenario while using following code snippet with Aspose.PDF for .NET 18.5 and were unable to notice the issue. Font size in the resultant PDF was fine. Please check attached output PDF file for your reference.

Document doc = new Document(dataDir + "S-0121 Stock PAA - ORIGINAL.pdf");
TextBoxField tbf = ((TextBoxField)doc.Form["_freight_terms"]);
tbf.DefaultAppearance.FontSize = 20;
tbf.Value = "MyValue";
doc.Save(dataDir + "S-0121 Stock PAA - Modified.pdf");

S-0121 Stock PAA - Modified.pdf (38.5 KB)

Please try using latest version of the API i.e. Aspose.PDF for .NET 18.5 and in case the issue still persists, please share a sample console application, able to reproduce the issue. We will again test the scenario in our environment and address it accordingly.

1 Like