0

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.

Boldrino
  • 11
  • 3
  • Possible duplicate of [Set different parts of a form field to have different fonts using iTextSharp](http://stackoverflow.com/questions/4410895/set-different-parts-of-a-form-field-to-have-different-fonts-using-itextsharp) – Essex Jun 30 '16 at 09:02
  • I don't think that's the answer – Boldrino Jun 30 '16 at 12:20
  • *more fields with the same name* - a PDF only contains one field with a given name. That field may have multiple widgets. By definition, though, they all have the same value (even though it may appear differently if the widgets have differing appearance streams). – mkl Jun 30 '16 at 13:18

1 Answers1

1

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
Boldrino
  • 11
  • 3