【问题标题】:Error when exporting data to PDF from C#从 C# 将数据导出为 PDF 时出错
【发布时间】:2012-02-18 09:26:26
【问题描述】:

我正在用 C# 编写一个 PDF 文件,如下所示:

Response.ContentType = "application/vnd.pdf";
Response.AddHeader("content-disposition", "attachment;filename=test.pdf");
Response.Write("<table border='1px'>");

/* Print Headers */
Response.Write("<tr>");
Response.Write("<th colspan='" + colspan + "'style='background-color:SlateGray;font-size:16;height:25;color:white;'><b>List of Candidates  "</b></th>");
Response.Write("</tr>");
Response.Write("<tr>");

当我保存文件并打开它时,它会抛出一个异常,即文件不支持文件类型..或文件已损坏。

【问题讨论】:

  • 您正在编写 tr,td 并希望将其导出为 pdf 格式?这是不可能的..你应该看看 iTextSharp。

标签: c# asp.net


【解决方案1】:

要创建 pdf 表单 html,您应该看看它。

Render PDF in iTextSharp from HTML with CSS

使用 itextsharp 创建表看看它

http://www.mikesdotnetting.com/Article/86/iTextSharp-Introducing-Tables

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-24
    • 2018-05-03
    相关资源
    最近更新 更多