Reputation: 21
I need to get the Font information, name and size from a specific field in the pdf form. In the pdf there are more fields with the same name and different Font and I don't want to edit the pdf field's names. I'm using Itexsharp. Can anyone help me with this? Thank you.
Upvotes: 0
Views: 1626
Reputation: 21
I solved, It works like this:
Private Sub FieldsFontProperties(ByVal Path As String)
Dim Reader As PdfReader = New PdfReader(Path)
Dim Fields As AcroFields = Reader.AcroFields
For Each Field In Fields.Fields
Dim Item As AcroFields.Item = Fields.GetFieldItem(Field.Key)
Dim TextField As TextField = New TextField(Nothing, Nothing, Nothing)
Fields.DecodeGenericDictionary(Item.GetMerged(0), TextField)
Dim t As String()() = TextField.Font.FullFontName
Dim FontName As String = t(0)(3)
Dim FontSize As Single = TextField.FontSize
Next
End Sub
Upvotes: 2