title: embed font with iTextSharp
body: <p>I am having problems embedding a font using iTextSharp.
  Basically I have a pdf document as a template with several text fields. 3 fonts are used, which need to be embedded, ITCCharterCom-Regular, ITCCharterCom-Italic and ITCCharterCom-BlackItalic.</p>
  
  <p>All is fine, except for the ITCCharterCom-BlackItalic font. The italic and regular are embedded, but not the black italic. Anyone any ideas on what I do wrong?</p>
  
  <p>Below is a simplified code extract.</p>
  
  <pre><code>    Private Function saveBusinessCard() As String
  
      ' init
      Dim template As String = Server.MapPath("~/Resources/BC_Template.pdf")
      Dim pdfOutput As String = String.Format("~/Temp/{0}.pdf", HttpContext.Current.Session.SessionID.ToString())
      Dim output As String = Server.MapPath(pdfOutput)
      Dim reader As New PdfReader(template)
      Dim pdfOutputFile As FileStream = New FileStream(output, FileMode.Create)
      Dim stamper As New PdfStamper(reader, pdfOutputFile)
      Dim form As AcroFields = stamper.AcroFields
  
      ' font property name
      Dim textFontPropertyName = "textfont"
  
      ' font installation files
      Dim pathBlackItalic As String = HttpContext.Current.Server.MapPath("~\Resources\Fonts\ITCCharterCom-BlackItalic.ttf")
      Dim pathItalic As String = HttpContext.Current.Server.MapPath("~\Resources\Fonts\ITCCharterCom-Italic.ttf")
      Dim pathRegular As String = HttpContext.Current.Server.MapPath("~\Resources\Fonts\ITCCharterCom-Regular.ttf")
  
      ' create embedded fonts
      Dim blackItalic As BaseFont = BaseFont.CreateFont(pathBlackItalic,
                                                        BaseFont.IDENTITY_H,
                                                        BaseFont.EMBEDDED)
      Dim italic As BaseFont = BaseFont.CreateFont(pathItalic,
                                                   BaseFont.IDENTITY_H,
                                                   BaseFont.EMBEDDED)
      Dim regular As BaseFont = BaseFont.CreateFont(pathRegular,
                                                    BaseFont.IDENTITY_H,
                                                    BaseFont.EMBEDDED)
  
      ' assign fonts to text fields
      form.SetFieldProperty("txtContact", textFontPropertyName, italic, Nothing)
      form.SetFieldProperty("txtName", textFontPropertyName, blackItalic, Nothing)
      form.SetFieldProperty("txtTitle", textFontPropertyName, regular, Nothing)
  
      ' set pdf fields in document
      form.SetField("txtContact", "Contact here")
      form.SetField("txtName", "Name here")
      form.SetField("txtTitle", "Title here")
  
      ' make input fields plain text
      stamper.FormFlattening = True
  
      ' clean up
      stamper.Close()
      reader.Close()
      pdfOutputFile.Close()
  
      ' return output path
      Return pdfOutput
  
  End Function
  </code></pre>
  
  <p>Thanks,
  Tom</p>