Ekrem Tapan

Ekrem Tapan

  • NA
  • 967
  • 81k

Html Table export to PDF with iTextSharp Library

Jun 4 2016 5:22 AM

Im using stringbuilder creating dynamically html table on codebehind. but when i export html table to pdf, chinese charachter column is blank like that below picture and not include style.

currently my pdf output is :

 
 
and html table is :
 
 
 

how can i resolve

and my code is :

  1. Response.ContentType = "application/pdf";  
  2. Response.AddHeader("content-disposition""attachment;filename=TestPage.pdf");  
  3. Response.Charset = "UTF-8";  
  4. Response.ContentEncoding = System.Text.Encoding.UTF8;  
  5. Response.Cache.SetCacheability(HttpCacheability.NoCache);  
  6. StringWriter sw = new StringWriter();  
  7. HtmlTextWriter hw = new HtmlTextWriter(sw);  
  8. this.Page.RenderControl(hw);  
  9. StringReader sr = new StringReader(sw.ToString());  
  10. Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);  
  11. HTMLWorker htmlparser = new HTMLWorker(pdfDoc);  
  12. PdfWriter.GetInstance(pdfDoc, Response.OutputStream);  
  13. pdfDoc.Open();  
  14. htmlparser.Parse(sr);  
  15. pdfDoc.Close();  
  16. Response.Write(pdfDoc);  
  17. Response.End();  
 

Answers (2)