How do I programmatically determine the alignment and font size of a PDF form field using iTextSharp?
I am using iTextSharp to populate a PDF that contains form fields. Originally, I was populating the form fields using the standard approach:
stamper.AcroFields.SetField("field_name", "value");
But I need the ability to use different formatting in a value, such as including bold text. I am working from this Stackoverflow question/answer, which, in a nutshell, creates a simple column, populates it with a paragraph generated from HTML and then puts that resulting paragraph on top of the corresponding form field.
This is working, but there are some shortcomings. Particularly, it always left aligns the content, but the form field may be setup to center align. Likewise, it seems to use a font size that is slightly larger than what would normally fit in the form field.
This Stackoverflow question/answer shows how to get the font name used by a form field. But I'm at a loss as to how to get the font size and the alignment. It appears this information is buried within the depths of the PDF, but not accessible via properties iTextSharp (without delving into PdfDictionary
s and PdfArray
s and the like).
So my question is, How do I programmatically determine the alignment and font size of a PDF form field using iTextSharp?
Thanks