将HTML表格导出为PDF [英] Export Html Table To PDF

查看:105
本文介绍了将HTML表格导出为PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于将表数据导出为PDF,我写了这样的代码

for Exporting Table Data to PDF i wrote code like this

HtmlForm form = new HtmlForm();
            string attachment = "attachment; filename=ExportPDf.pdf";
            Response.ClearContent();
            Response.AddHeader("content-disposition", attachment);
            Response.ContentType = "application/pdf";
            StringWriter stw = new StringWriter();
            HtmlTextWriter htextw = new HtmlTextWriter(stw);
            form.Controls.Add(Table3);
            Table3.RenderControl(htextw);

            lblMessbody.RenderControl(htextw);

            Response.Write(stw.ToString());
            Response.End();



但它不会导出为PDF格式,

它显示了这样的错误,例如AdobeReader无法打开".pdf",因为它不是受支持的文件类型,或者因为文件已损坏



but it''s not export to PDF format,

it shows the error like this AdobeReader could not open " .pdf" becz it is either not a supported file type or because the file has been damaged

推荐答案

.NET内置的PDF支持.您需要使用一个外部库.使用google,有免费的.
There is no PDF support built in to .NET. You need to use an external library. Use google, there are free ones.


hii请参阅这篇文章,

使用ASP.NET从HTML页面生成PDF文档 [ ^ ]
hii please refer this article,

Generate PDF documents from a HTML page using ASP.NET[^]


这篇关于将HTML表格导出为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆