本文介绍了使用asp.net C#ITEXT Sharp libaray将带有arabic和css的html表数据导出为PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-1下来投票最爱





我正在报告。我有以下代码。当我运行代码阿拉伯字体并且css没有在pdf中显示。我想使用itext sharp free库将相同的html表数据格式转换为pdf但无法转换指导我如何在itext中显示阿拉伯数据和css。

OR哪个免费库我用html来pdf。



-1 down vote favorite


I am making a report.I have following code.When i run the code Arabic font and css not showing in pdf.I want to convert same html table data format into pdf using itext sharp free library but unable to convert guide me how Arabic data and css show in itext sharp.
OR which free library I used html to pdf.

protected void Button1_Click(object sender, EventArgs e)
        {
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            tblid1.RenderControl(hw);
            StringReader sr = new StringReader(sw.ToString());
            Document pdfDoc = new Document(PageSize.A4, 80f, 80f, -2f, 35f);
            HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
            PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
            pdfDoc.Open();
            htmlparser.Parse(sr);
            pdfDoc.Close();
            Response.Write(pdfDoc);
            Response.End();
        }







<table   border="1" id="tblid1"  runat="server">
      <tr class="bgtd1">
        <td colspan="2" rowspan="2" class="title">Region</td>
        <td  colspan="3" class="title"><span id="result_box" lang="ar" xml:lang="ar">المجموع العام</span></td>
        <td colspan="2" class="title"> سلطانالخارج</td>
        <td colspan="2" class="title">مسندم</td>
        <td colspan="2" class="title">مسندم</td>
        <td colspan="2" class="title">مسندم</td>
        <td colspan="2" class="title">مسندم</td>
        <td colspan="2" class="title">مسندم</td>
        <td colspan="2" class="title">مسندم</td>
        <td colspan="2" class="title">مسندم</td>
        <td colspan="2" class="title">مسندم</td>
        <td colspan="2" class="title">مسندم</td>
        <td colspan="2" class="title">مسندم</td>
        <td colspan="2" class="title">مسندم</td>
        <td colspan="2" rowspan="2" class="title"><span id="result_box2" lang="ar" xml:lang="ar">منطقة</span></td>
      </tr>
      <tr class="bgtd1">
        <td  colspan="3" class="auto-style1">Grand Total</td>
        <td colspan="2" class="auto-style1">  </td>
        <td colspan="2" class="auto-style1">
             Musandam </td>
        <td colspan="2" class="auto-style1"> Al-wuta </td>
        <td colspan="2" class="auto-style1"> Alb </td>
        <td colspan="2" class="auto-style1"> Al-Dhra </td>
        <td colspan="2" class="auto-style1"> Dor </td>
        <td colspan="2" class="auto-style1">  Al-dhh </td>
        <td colspan="2" class="auto-style1"> Al-arqiya(n) </td>
        <td colspan="2" class="auto-style1"> Al-sharyah </td>
        <td colspan="2" class="auto-style1"> Albaniah(s) </td>
        <td colspan="2" class="auto-style1"> Al-Aatinah </td>
        <td colspan="2" class="auto-style1"> Mcat </td>
      </tr>
      <tr>
        <td colspan="2" class="bgtd1">Gender</td>
        <td class="title"><span id="result_box8" lang="ar" xml:lang="ar"> مجموع </span></td>
        <td >١</td>
        <td class="titleMale"</td>
        <td >١</td>
        <td class="titleMale"</td>
        <td >١</td>
        <td class="auto-style2"</td>
        <td >١</td>
        <td class="titleMale"</td>
        <td>١</td>
        <td class="titleMale"</td>
        <td >١</td>
        <td class="titleMale"</td>
        <td >١</td>
        <td class="titleMale"</td>
        <td >١</td>
        <td class="titleMale"</td>
        <td >١</td>
        <td class="titleMale"</td>
        <td>١</td>
        <td class="titleMale"</td>
        <td>١</td>
        <td class="titleMale"</td>
        <td>١</td>
        <td class="titleMale"</td>
        <td >١</td>
        <td class="titleMale"</td>
        <td colspan="2" class="bgtd1"><span id="result_box3" lang="ar" xml:lang="ar">جنس</span></td>
      </tr>
      <tr>
        <td colspan="2" class="bgtd1">Specialization</td>
        <td class="title">Total</td>
        <td>F</td>
        <td class="titleMale">M</td>
        <td>F</td>
        <td class="titleMale">M</td>
        <td>F</td>
        <td class="auto-style2">M</td>
        <td>F</td>
        <td class="titleMale">M</td>
        <td>F</td>
        <td class="titleMale">M</td>
        <td>F</td>
        <td class="titleMale">M</td>
        <td>F</td>
        <td class="titleMale">M</td>
        <td>F</td>
        <td class="titleMale">M</td>
        <td>F</td>
        <td class="titleMale">M</td>
        <td>F</td>
        <td class="titleMale">M</td>
        <td>F</td>
        <td class="titleMale">M</td>
        <td>F</td>
        <td class="titleMale">M</td>
        <td>F</td>
        <td class="titleMale">M</td>
        <td colspan="2" class="bgtd1" ><span id="result_box4" lang="ar" xml:lang="ar">تخصص</span></td>
      </tr>
      <tr>
        <td  rowspan="4" class="bgtd1"><div class="repFont bgtd1">Foundation</div></td>
        <td class="bgtd1">Eng</td>
        <td >120</td>
        <td>48</td>
        <td class="titleMale">72</td>
        <td>0</td>
        <td  class="titleMale">0</td>
        <td>0</td>
        <td  class="auto-style2">0</td>
        <td>1</td>
        <td  class="titleMale">1</td>
        <td>0</td>
        <td  class="titleMale">0</td>
        <td>1</td>
        <td  class="titleMale">1</td>
        <td>0</td>
        <td>0</td>
        <td>1</td>
        <td  class="titleMale">1</td>
        <td>0</td>
        <td  class="titleMale">0</td>
        <td>1</td>
        <td  class="titleMale">1</td>
        <td>0</td>
        <td  class="titleMale">0</td>
        <td>1</td>
        <td  class="titleMale">1</td>
        <td>0</td>
        <td  class="titleMale">0</td>
        <td class="bgtd1">الهندسة </td>
        <td  rowspan="4" class="bgtd1"><div  class="repFont "> مؤسسة </div></td>
      </tr>
      <tr>
          <td class="bgtd1">Science</td>
        <td>213</td>
        <td>147</td>
        <td class="titleMale">66</td>
        <td>1</td>
        <td  class="titleMale">2</td>
        <td>0</td>
        <td  class="auto-style2">0</td>
        <td>1</td>
        <td  class="titleMale">1</td>
        <td>0</td>
        <td  class="titleMale">0</td>
        <td>1</td>
        <td  class="titleMale">1</td>
        <td>0</td>
        <td>0</td>
        <td>1</td>
        <td  class="titleMale">1</td>
        <td>0</td>
        <td  class="titleMale">0</td>
        <td >1</td>
        <td  class="titleMale">1</td>
        <td>0</td>
        <td  class="titleMale">0</td>
        <td>1</td>
        <td  class="titleMale">1</td>
        <td>0</td>
        <td  class="titleMale">0</td>
        <td class="bgtd1"> تكنولوجيا المعلومات </td>
      </tr>
      <tr>
        <td rowspan="2" class="bgtd1"><span class="titleTotal">Total</span></td>
        <td rowspan="2">313</td>
        <td >195</td>
        <td  class="titleMale">138</td>
        <td>1</td>
        <td  class="titleMale">2</td>
        <td>0</td>
        <td  class="auto-style2">0</td>
        <td>2</td>
        <td  class="titleMale">2</td>
        <td>0</td>
        <td  class="titleMale">0</td>
        <td>2</td>
        <td  class="titleMale">2</td>
        <td>0</td>
        <td>0</td>
        <td>2</td>
        <td  class="titleMale">2</td>
        <td>0</td>
        <td  class="titleMale">0</td>
        <td>2</td>
        <td  class="titleMale">2</td>
        <td>0</td>
        <td  class="titleMale">0</td>
        <td>2</td>
        <td  class="titleMale">2</td>
        <td>0</td>
        <td  class="titleMale">0</td>
        <td rowspan="2" class="bgtd1" >إجمالي</td>
      </tr>
      <tr>
        <td colspan="2">313</td>
        <td colspan="2">3</td>
        <td colspan="2">0</td>
        <td colspan="2">4</td>
        <td colspan="2">0</td>
        <td colspan="2">4</td>
        <td colspan="2">0</td>
        <td colspan="2">4</td>
        <td colspan="2">0</td>
        <td colspan="2">4</td>
        <td colspan="2">0</td>
        <td colspan="2">4</td>
        <td colspan="2">0</td>
      </tr>
    </table>

推荐答案

这篇关于使用asp.net C#ITEXT Sharp libaray将带有arabic和css的html表数据导出为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 08:31