Darshan Kshirasagar

Darshan Kshirasagar

  • NA
  • 317
  • 68.9k

iTextSharp convert to Unicode PDF Not Working

Jan 31 2017 2:17 AM
HTML :
 
<asp:Panel ID="pnlPerson" runat="server">
<div id="div1" style="background-color: white; padding: 0 1px 1px 0; border-top: 0;
border: none;">
<table class="tHead" style="width: 978px;">
<tr>
<td width=" 15px">
</td>
<td width=" 978 px" align="center">
<table class="tHead" style="width: 100%;">
<tr>
<td width="33%">
</td>
<td align="center" width="34%">
</td>
<td align="right" width="33%">
Run Date: 27/01/2017 (16:19)
</td>
</tr>
<tr>
<td width="33%">
</td>
<td align="center" width="34%">
</td>
<td align="right" width="33%">
</td>
</tr>
<tr>
<td width="33%">
???????? ????? : 22431265,22504903
</td>
<td align="center" width="34%">
</td>
<td align="right" width="33%">
</td>
</tr>
<tr>
<td align="center" colspan="3" width="100%">
??? ????? ???? ??????? (602)
</td>
</tr>
<tr>
<td align="center" colspan="3" width="100%">
??? ??? 03/04/2015
</td>
</tr>
</table>
<table class="tBody" style="width: 100%;">
<tr>
<td width="34%" class="LineStyleTopBottom">
??????
</td>
<td align="right" width="15%" class="LineStyleTopBottom">
??????
</td>
<td align="center" width="2%" class="LineStyleTopBottom">
|
</td>
<td width="34%" class="LineStyleTopBottom">
????????
</td>
<td align="right" width="15%" class="LineStyleTopBottom">
??????
</td>
</tr>
<tr>
<td width="34%" class="Ellipsis">
1. ???????? ?????? ?????
</td>
<td align="right" width="15%" class="Ellipsis">
</td>
<td align="center" width="2%">
|
</td>
<td width="34%" class="Ellipsis">
6. ??????? ?????? ??????????
</td>
<td align="right" width="15%" class="Ellipsis">
</td>
</tr>
<tr>
<td width="34%" class="Ellipsis">
&nbsp&nbsp&nbsp?????? ??? / ?? ?????? ????????
</td>
<td align="right" width="15%" class="Ellipsis">
13,85,63,001.30 ????
</td>
<td align="center" width="2%">
|
</td>
<td width="34%" class="Ellipsis">
??????? ???? ?????????? ??????
</td>
<td align="right" width="15%" class="Ellipsis">
1,28,928.00 ????
</td>
</tr>
<tr>
<td width="34%" class="Ellipsis">
&nbsp&nbsp&nbsp????????? ??? ??? ???????? ????. ??????
</td>
<td align="right" width="15%" class="Ellipsis">
80,66,039.00 ????
</td>
<td align="center" width="2%">
|
</td>
<td width="34%" class="Ellipsis">
????????? ????????? ??? ???????? ???????
</td>
<td align="right" width="15%" class="Ellipsis">
16,700.00 ????
</td>
</tr>
<tr>
<td width="34%" class="Ellipsis">
&nbsp&nbsp&nbsp????? ?????? ?????? ??
</td>
<td align="right" width="15%" class="Ellipsis">
408.00 ????
</td>
<td align="center" width="2%">
|
</td>
<td width="34%" class="Ellipsis">
???????????? ????????? ????? ??????
</td>
<td align="right" width="15%" class="Ellipsis">
23,91,252.96 ????
</td>
</tr>
<tr>
<td width="34%" class="Ellipsis">
&nbsp&nbsp&nbsp????????? ??? ??? ???? ?????? ??
</td>
<td align="right" width="15%" class="Ellipsis">
2,87,498.00 ????
</td>
<td align="center" width="2%">
|
</td>
<td width="34%" class="Ellipsis">
????????? ????????? ??? ???????? ????
</td>
<td align="right" width="15%" class="Ellipsis">
9,758.00 ????
</td>
</tr>
<tr>
<td width="34%" class="Ellipsis">
????? ???? ???? ???? ????????
</td>
<td align="right" width="15%" class="Ellipsis">
1,36,170.00 ????
</td>
<td align="center" width="2%">
|
</td>
<td width="34%" class="Ellipsis">
-
</td>
<td align="right" width="15%" class="Ellipsis">
</td>
</tr>
<tr>
<td width="34%" class="Ellipsis">
-
</td>
<td align="right" width="15%" class="Ellipsis">
</td>
<td align="center" width="2%">
|
</td>
<td width="34%" class="Ellipsis">
????? ?????? ??????
</td>
<td align="right" width="15%" class="Ellipsis">
28,141.00 ????
</td>
</tr>
<tr>
<td width="34%" class="Ellipsis">
2. ???????? ????????
</td>
<td align="right" width="15%" class="Ellipsis">
</td>
<td align="center" width="2%">
|
</td>
<td width="34%" class="Ellipsis">
?????? ???????????? ????
</td>
<td align="right" width="15%" class="Ellipsis">
2,250.00 ????
</td>
</tr>
<tr>
<td width="34%" class="Ellipsis">
-
</td>
<td align="right" width="15%" class="Ellipsis">
</td>
<td align="center" width="2%">
|
</td>
<td width="34%" class="Ellipsis">
???? ??????? ???????
</td>
<td align="right" width="15%" class="Ellipsis">
760.00 ????
</td>
</tr>
<tr>
<td width="34%" class="Ellipsis">
3. ?????????? ????????
</td>
<td align="right" width="15%" class="Ellipsis">
</td>
<td align="center" width="2%">
|
</td>
<td width="34%" class="Ellipsis">
?????. ?????? / ??????? / ??????? / ??????? / ??? ????????????
</td>
<td align="right" width="15%" class="Ellipsis">
790.00 ????
</td>
</tr>
<tr>
<td width="34%" class="Ellipsis">
</td>
<td align="right" width="15%" class="Ellipsis">
</td>
<td align="center" width="2%">
|
</td>
<td width="34%" class="Ellipsis">
????. ???? ??????
</td>
<td align="right" width="15%" class="Ellipsis">
157.00 ????
</td>
</tr>
<tr>
<td width="34%" class="Ellipsis">
</td>
<td align="right" width="15%" class="Ellipsis">
</td>
<td align="center" width="2%">
|
</td>
<td width="34%" class="Ellipsis">
???? ????
</td>
<td align="right" width="15%" class="Ellipsis">
3,49,226.14 ????
</td>
</tr>
<tr>
<td width="34%" class="LineStyleTopBottom">
?????:
</td>
<td align="right" width="15%" class="LineStyleTopBottom">
14,70,53,116.30 ????
</td>
<td align="center" width="2%" class="LineStyleTopBottom">
|
</td>
<td width="34%" class="LineStyleTopBottom">
?????:
</td>
<td align="right" width="15%" class="LineStyleTopBottom">
18,54,542.82 ????
</td>
</tr>
</table>
<table class="tHead" style="width: 100%;">
<tr>
<td colspan="3" width="100%">
</td>
</tr>
<tr>
<td width="100%" colspan="3">
<br />
<br />
<br />
<br />
</td>
</tr>
<tr>
<td align="right" colspan="2" width="67%">
</td>
<td align="center" width="33%">
?????? ???
</td>
</tr>
</table>
</td>
<td width=" 15px">
</td>
</tr>
</table>
</div>
</asp:Panel> 
 
 
My Code is :
 
protected void btnExport3_Click(object sender, EventArgs e)
{
byte[] bytesArray = null;

StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
pnlPerson.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());

string filename = "PaySlip123";
string html = sw.ToString();
html = html.Replace("px", "");
html = html.Replace("<br>", "<br/>");
html = html.Replace("&nbsp", " ");

//Register a single font
FontFactory.Register(Path.Combine(System.Environment.GetEnvironmentVariable("windir"), "Fonts") + "\\ArialUni.TTF", "Arial Unicode MS");

using (var ms = new MemoryStream())
{
using (var document = new Document(PageSize.A4,0,0,0,0))
{
using (PdfWriter writer = PdfWriter.GetInstance(document, ms))
{
document.Open();
using (var strReader = new StringReader(html))
{
//Set factories
HtmlPipelineContext htmlContext = new HtmlPipelineContext(null);
htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());
//Set css
ICSSResolver cssResolver = XMLWorkerHelper.GetInstance().GetDefaultCssResolver(false);
cssResolver.AddCssFile(System.Web.HttpContext.Current.Server.MapPath("~/PrintStyle.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();
}
Response.Clear();
MemoryStream ms1 = new MemoryStream(bytesArray);
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=labtest.pdf");
Response.Buffer = true;
ms1.WriteTo(Response.OutputStream);
Response.End();
 
 I am converting html table to pdf but unicode(Kannada) text not coming in pdf file .
 

Answers (1)