title: itextsharp "razor to html" works fine but "to pdf" ignores styles
body: <p>I am wondering if itextsharp only accepts <code>&lt;table&gt;</code>. Is the problem using <code>&lt;div&gt;</code>s?</p>
  
  <p>external css file below is invoked from the cshtml. Same code works fine to create html, fails with pdf. I am using <code>XMLWorkerHelper</code>.</p>
  
  <p>RenderViewToString Method:</p>
  
  <pre><code>public class HtmlViewRenderer
  {
      public string RenderViewToString(Controller controller, string viewName, object viewData)
      {
          var renderedView = new StringBuilder();
          using (var responseWriter = new StringWriter(renderedView))
          {
              var fakeResponse = new HttpResponse(responseWriter);
              var fakeContext = new HttpContext(HttpContext.Current.Request, fakeResponse);
              var fakeControllerContext = new ControllerContext(new HttpContextWrapper(fakeContext), controller.ControllerContext.RouteData, controller.ControllerContext.Controller);
  
              var oldContext = HttpContext.Current;
              HttpContext.Current = fakeContext;
  
              using (var viewPage = new ViewPage())
              {
                  var html = new HtmlHelper(CreateViewContext(responseWriter, fakeControllerContext), viewPage);
                  html.RenderPartial(viewName, viewData);
                  HttpContext.Current = oldContext;
              }
          }
  
     return renderedView.ToString();
  }
  private static ViewContext CreateViewContext(TextWriter responseWriter, ControllerContext fakeControllerContext)
  {
          return new ViewContext(fakeControllerContext, new FakeView(), new ViewDataDictionary(), new TempDataDictionary(), responseWriter);
  }
  }
  </code></pre>
  
  <p>StandardPdfRenderClass - Render Method:</p>
  
  <pre><code>public class StandardPdfRenderer
  {
      private const int HorizontalMargin = 10;
      private const int VerticalMargin = 10;
  
      public byte[] Render(string htmlText, string pageTitle)
      {
  
          byte[] renderedBuffer;
  
          //BaseFont Vn_Helvetica = BaseFont.CreateFont(@"C:\Windows\Fonts\arial.ttf", "Identity-H", iTextSharp.text.pdf.BaseFont.EMBEDDED);
          BaseFont Vn_Helvetica = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, false);
          Font fontNormal = new Font(Vn_Helvetica, 12, iTextSharp.text.Font.NORMAL);
          using (var outputMemoryStream = new MemoryStream())
          {
              using (var pdfDocument = new Document(PageSize.A3, HorizontalMargin, HorizontalMargin, 110, 30))
              {
                  PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDocument, outputMemoryStream);
                  pdfWriter.CloseStream = false;
                  pdfWriter.PageEvent = new PrintHeaderFooter();
  
                  using (var htmlViewReader = new StringReader(TurkceKarakter(htmlText)))
                  {
                     pdfDocument.Open(); 
                     XMLWorkerHelper.GetInstance().ParseXHtml(pdfWriter, pdfDocument, htmlViewReader);
                      //used to be like this. Changed it to include XMLWorkerHelper up there.
                      //using (var htmlWorker = new HTMLWorker(pdfDocument))
                      //{                          
                      //    htmlWorker.Parse(htmlViewReader);
                      //}
                  }
              }
  
              renderedBuffer = new byte[outputMemoryStream.Position];
              outputMemoryStream.Position = 0;
              outputMemoryStream.Read(renderedBuffer, 0, renderedBuffer.Length);
          }
  
          return renderedBuffer;
      }
  
      public string TurkceKarakter(string text)
      {
  
          text = text.Replace("İ", "I");
          text = text.Replace("ı", "i");
          text = text.Replace("Ş", "S");
          text = text.Replace("ş", "s");
          text = text.Replace("Ğ", "G");
          text = text.Replace("ğ", "g");
          text = text.Replace("Ö", "Ö");
          text = text.Replace("ö", "ö");
          text = text.Replace("ç", "c");
          text = text.Replace("Ç", "C");
          text = text.Replace("ü", "ü");
          text = text.Replace("Ü", "Ü");
          return text;
      }
  }
  </code></pre>
  
  <p>Here is the cshtml:</p>
  
  <pre><code>&lt;div id="maincontainer"&gt;
  &lt;div id="maincontent"&gt;        
      &lt;div class="section group"&gt;
          &lt;div class="col span_1_of_1"&gt;
              &lt;div class="baslik"&gt;&lt;span class="mavi"&gt;.&lt;/span&gt;&lt;h3&gt;CV&lt;/h3&gt;&lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="section group"&gt;
          &lt;div class="col span_1_of_2"&gt;
              &lt;div&gt; 
                  &lt;img src="@(helper.StaticUrl + helper.Detay.Detay.GenelBilgi.Resim)" width="180" alt="Resim" /&gt;                       
              &lt;/div&gt;
              &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
              &lt;div class="col span_1_of_1 clearfix"&gt;
              &lt;div class="isim"&gt;
                  &lt;span class="adisoyadi"&gt;@(helper.Detay.Detay.GenelBilgi.AdiSoyadi.ToUpper())&lt;/span&gt; 
                                 &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;          
          &lt;div class="col span_1_of_2 clearfix"&gt;
              &lt;dl class="iletisim"&gt;
                  &lt;dt class="uk-icon-mobile"&gt;Telefon&lt;/dt&gt;
                  &lt;dd&gt;@(helper.Detay.Detay.GenelBilgi.CepTelefonUlkeKod) @(helper.Detay.Detay.GenelBilgi.CepTelefon) &lt;/dd&gt;
                  &lt;dt class=" uk-icon-email"&gt;E-mail&lt;/dt&gt;
                  &lt;dd&gt;@(helper.Detay.Detay.GenelBilgi.Email)&lt;/dd&gt;
                  &lt;dt class="uk-icon-adres"&gt;Adres&lt;/dt&gt;
                  &lt;dd&gt;@(helper.Detay.Detay.GenelBilgi.Adres) &lt;/dd&gt;
                  &lt;dt class="uk-icon-adres"&gt;Doğum Tarihi&lt;/dt&gt;
                  &lt;dd&gt;@(helper.Detay.Detay.GenelBilgi.DogumTarihi)&lt;/dd&gt;
                  &lt;dt class="uk-icon-adres"&gt;Medeni Durum&lt;/dt&gt;
                  &lt;dd&gt;@(helper.Detay.Detay.GenelBilgi.MedeniDurum)&lt;/dd&gt;
                  @if (!string.IsNullOrEmpty(helper.Detay.Detay.GenelBilgi.AskerlikDurum))
                  {
                      &lt;dt class=" uk-icon-adres"&gt;Askerlik&lt;/dt&gt;
                      &lt;dd&gt;@(helper.Detay.Detay.GenelBilgi.AskerlikDurum)&lt;/dd&gt;
                  }
                  &lt;dt class="uk-icon-adres"&gt;Çalışma Durumu&lt;/dt&gt;
                  &lt;dd&gt;@(helper.Detay.Detay.GenelBilgi.CalismaDurum.HasValue ? helper.Detay.Detay.GenelBilgi.CalismaDurum.Value ? "Çalışıyor" : "Çalışmıyor" : "")&lt;/dd&gt;
              &lt;/dl&gt;
          &lt;/div&gt;          
          &lt;div class="col span_1_of_1 aciklama"&gt;              
          &lt;/div&gt;
      &lt;/div&gt;   
   &lt;/div&gt;
   &lt;/div&gt;
  </code></pre>