0

I am using stringbuilder to create dynamically html table on codebehind. But when I export html table to pdf, Chinese character column is blank like that below picture and not include style.

currently my pdf output is : enter image description here

and html table is : enter image description here How can I resolve

And my code is :

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
Response.Charset = "UTF-8";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
Jaimesh
  • 841
  • 4
  • 25
  • 41
ekrem tapan
  • 147
  • 4
  • 15
  • 1
    You are using `HTMLWorker` instead of XML Worker. `HTMLWorker` has been abandoned a long time ago. Moreover: you don't define a font that knows how to render Chinese characters. In the answer to the duplicate question, I explain how to define a font as well as the correct encoding to convert HTML with Chinese glyphs to PDF. – Bruno Lowagie Jun 04 '16 at 09:49
  • **a** `HTMLWorker` has been deprecated a long time ago. **b** to investigate into such issues one needs the HTML string in question. – mkl Jun 04 '16 at 11:32

0 Answers0