小编raj*_*aje的帖子

使用itextsharp将HTML转换为PDF

当使用itextsharp样式ist 将html转换为pdf时,使用css为网页应用转换后的pdf无法正常工作.

这是我的css代码:

<style type="text/css">
       .cssformat
            {
                width:300px;
                height:200px;
                border:2px solid black;
                background-color:white; 
                border-top-left-radius:60px 90px; 
                border-bottom-right-radius:60px 90px;
        }                
        </style>
Run Code Online (Sandbox Code Playgroud)

这是我的HTML代码:

      <div id="divpdf" runat="server">
        <table id="tid" runat="server">
        <tr>
        <td>
       <asp:Label ID="Label1" runat="server" Text="this is new way of pdf" CssClass="cssformat"></asp:Label>
        </td>
        </tr>
        </table>
        </div>
Run Code Online (Sandbox Code Playgroud)

以下是我用c#试过的内容:

 Response.ContentType = "application/pdf";
        Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        StringBuilder sb = new StringBuilder();
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);
        Document pdfDoc = new Document(PageSize.A4, 60f, 80f, -2f, 35f);
        divpdf.RenderControl(hw);
        StringReader sr = new …
Run Code Online (Sandbox Code Playgroud)

html css c# pdf asp.net

6
推荐指数
1
解决办法
7991
查看次数

标签 统计

asp.net ×1

c# ×1

css ×1

html ×1

pdf ×1