使用itextsharp导出到pdf不适用于嵌入式css

时间:2015-03-04 13:37:33

标签: c# asp.net itextsharp

我尝试了一些但没有工作......这里是我的代码

 <table cellpadding="2" cellspacing="0" style="background-color: #fcfcfc; border: 10px solid #d9e8ef; width: 100%; border-radius: 5px" 
                        id="tb_header" runat="server">
                        <tr>
                            <td align="right">
                                <span style="font-weight: bold; font-size: 27pt; font-family: Verdana">TAX INVOICE</span>
                            </td>
                        </tr>
                    </table>

它没有采用嵌入式CSS。我做错了什么?

这是我的c#

Response.ContentType = "application/pdf";
        Response.AddHeader("content-disposition", "attachment;filename=Panel.pdf");
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);

        tb_header.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);

        var ms = new MemoryStream();
        pdfDoc.Open();

        htmlparser.Parse(sr);
        pdfDoc.Close();
        Response.Write(pdfDoc);
        Response.End();

0 个答案:

没有答案