title: Missing Font Awesome icons in iTextSharp pdf
body: <p>I am trying to take HTML content and convert it to PDF using iTextSharp. Everything is working well except that the font-awesome icons do not appear in the resultant PDF. </p>
  
  <p>My .NET MVC application is written in C# and utilizes Font Awesome Free 5.0.12 (using <a href="https://fontawesome.com/get-started/web-fonts-with-css" rel="nofollow noreferrer">Web Fonts with CSS</a> method), iTextSharp 5.5.13 along with itextsharp.xmlworker, and Vue.js framework. </p>
  
  <p>When the "Print" button gets clicked from the browser, a vue.js method gets called that takes the contents of the HTML to be converted (which is contained in a hidden div) and posts it to the appropriate controller method (and in turn takes the response data and loads it):</p>
  
  <pre><code>createPDF: function () {
      commonEventBus.$emit("show-loading-overlay", "Loading");
  
      var document = $("#printSummary");
      var model = {
          HtmlData: document.html()
      }
      return this.$http.post(commonApp.root + "PDF/Export", model, { responseType: "blob" })
          .then(function (response) {
              if (window.navigator &amp;&amp; window.navigator.msSaveOrOpenBlob) { // for IE
                  window.navigator.msSaveOrOpenBlob(response.bodyBlob);
                  commonEventBus.$emit("hide-overlay");
              }
              else {
                  var fileURL = URL.createObjectURL(response.bodyBlob);
                  window.open(fileURL);
                  commonEventBus.$emit("hide-overlay");
              }
          });
  },
  </code></pre>
  
  <p>The Export method in the PDFController looks as such:</p>
  
  <pre><code>[HttpPost]
  [ValidateInput(false)]
  public ActionResult Export(HtmlViewModel model)
  {
      var generator = new PDFGenerator();
      return File(generator.Generate(model), "application/pdf", "Confirmation" + DateTime.Now + ".pdf");
  }
  </code></pre>
  
  <p>And the Generate method in the PDFGenerator class looks like this:</p>
  
  <pre><code>public byte[] Generate(HtmlViewModel html)
  {
      HtmlNode.ElementsFlags["br"] = HtmlElementFlag.Closed;
      HtmlNode.ElementsFlags["input"] = HtmlElementFlag.Closed;
      HtmlNode.ElementsFlags["hr"] = HtmlElementFlag.Closed;
      HtmlNode.ElementsFlags["img"] = HtmlElementFlag.Closed;
  
      HtmlDocument doc = new HtmlDocument();
      doc.OptionFixNestedTags = true;
      doc.LoadHtml(html.HtmlData);
      html.HtmlData = doc.DocumentNode.OuterHtml;
  
      byte[] bytesArray = null;
      using (var ms = new MemoryStream())
      {
          using (var document = new Document(PageSize.A4, 40, 40, 40, 40))
          {
              using (PdfWriter writer = PdfWriter.GetInstance(document, ms))
              {
                  document.Open();
                  using (var strReader = new StringReader(html.HtmlData))
                  {
                      //Set factories
                      HtmlPipelineContext htmlContext = new HtmlPipelineContext(null);
                      htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());
  
                      //Set css
                      ICSSResolver cssResolver = XMLWorkerHelper.GetInstance().GetDefaultCssResolver(false);
  
                      //Register a single font
                      cssResolver.AddCssFile(System.Web.HttpContext.Current.Server.MapPath("~/Content/bootstrap.css"), true);
                      cssResolver.AddCssFile(System.Web.HttpContext.Current.Server.MapPath("~/Content/app/print.css"), true);
  
                      //Export
                      IPipeline pipeline = new CssResolverPipeline(cssResolver, new HtmlPipeline(htmlContext, new PdfWriterPipeline(document, writer)));
                      var worker = new XMLWorker(pipeline, true);
                      var xmlParse = new XMLParser(true, worker);
                      xmlParse.Parse(strReader);
                      xmlParse.Flush();
                  }
                  document.Close();
              }
          }
          bytesArray = ms.ToArray();
      }
      return bytesArray;
  }
  </code></pre>
  
  <p>Any idea how to get the Font Awesome icons to show up? For instance, I have something like this in the HTML code that gets converted and it disappears in the PDF: </p>
  
  <pre><code>&lt;i class="fas fa-1x fa-shopping-cart"&gt;&lt;/i&gt; Print Order
  </code></pre>
  
  <p>I have also tried to use the unicode value instead but with no luck either:</p>
  
  <pre><code>&lt;i class="fas"&gt;&amp;#xf07a;&lt;/i&gt; Print Order
  </code></pre>