Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Mar 21, 2017 6:39 am

Hello,

I was trying to change the font of an existing textbox form field in a pdf while populating the text attribute but it was not working.

Code: Select all
textBox.Font = new PdfTrueTypeFont(new Font("Arial", 22f, FontStyle.Regular));
textBox.Text = "test";
textBox.ReadOnly = true;


The text is populated and the readonly property is set but the font size never changes.

I was able to work around this issue by drawing a string at the position where the textbox belongs but I was wondering if this is the only supported way to change fonts.

Code: Select all
page.Canvas.DrawString("test", new PdfTrueTypeFont(new Font("Arial", 22f, FontStyle.Regular)), PdfBrushes.Black, new PointF(textBox.Bounds.X, textBox.Bounds.Y));

nater
 
Posts: 1
Joined: Tue Mar 21, 2017 6:12 am

Tue Mar 21, 2017 7:24 am

Dear nater,

Thanks for your inquiry.
I have tested the case with the sample file I created, but it worked fine on my side. Please provide us your input PDF file for investigation.

Thanks,
Betsy
E-icbelue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF