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));