c#将asp.net中的gridview导出为pdf的问题 [英] problem in exporting gridview to pdf in asp.net using c#

查看:70
本文介绍了c#将asp.net中的gridview导出为pdf的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

plz帮助我解决将gridview导出为pdf时遇到的问题.

(itextsharp.dll已用于编码)

错误...无法将类型为"iTextSharp.text.html.simpleparser.CellWrapper"的对象转换为类型为"iTextSharp.text.Paragraph

代码:

plz help me to fix this problem i''m facing with exporting gridview to pdf..

(itextsharp.dll have been used in coding)

error...Unable to cast object of type ''iTextSharp.text.html.simpleparser.CellWrapper'' to type ''iTextSharp.text.Paragraph

code:

StringReader sr = new StringReader(sw.ToString());
       Document pdfDoc = new Document(PageSize.A4, 20f, 20f, 20f, 20f);
       HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
       PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
       pdfDoc.Open();
      ----> htmlparser.Parse(sr); <------- ERROR
       pdfDoc.Close();
       Response.Write(pdfDoc);
       Response.End();

推荐答案

看看我之前对类似问题的回答:如何使用iTextSharp将HTML转换为带有图像标签的PDF [
Have a look at my answer to similar asked question earlier: Exporting aspx page to pdf[^]

Also, refer the following to convert HTML to PDF if needed: How To Convert HTML To PDF With Image Tags Using iTextSharp[^]


这篇关于c#将asp.net中的gridview导出为pdf的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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