在C#和asp.net中使用itextsharp将Html转换为pdf

时间:2014-07-26 10:23:08

标签: c# html asp.net pdf itextsharp

html code ::

 <div id="divprint" runat="server">

 <table>
   <tr align="left">
          <td colspan="4" align="left">
              Employee Name :
          <asp:Label ID="lblename" runat="server" Text=""></asp:Label>
            </td>
    </tr>
     <tr align="left">
            <td colspan="4" align="left">
               Employee ID :
                <asp:Label ID="lbleid" runat="server" Text=""></asp:Label>
             </td>                        
    </tr>

我想转换此代码pdf这里是我的c#代码

 Document Doc = new Document(PageSize.A4, 72, 72, 82, 72);

   MemoryStream ms = new MemoryStream();
   PdfWriter writer = PdfWriter.GetInstance(Doc, ms);

   Doc.Open();
   Doc.add(divprint) **//showing error**
   Doc.Close();
   Response.ContentType = "application/pdf";
   Response.AddHeader("content-disposition", "attachment; filename=Bhagavan.pdf");
   Response.End();

我想将此HTML代码转换为PDf。我是Itextsharp的新手。请给出一些提示。

0 个答案:

没有答案