pdf在asp.net c#中产生错误 [英] pdf generating error in asp.net c#

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

问题描述



我正在尝试使用itextsharp创建pdf文件,以便我使用以下代码.
我收到>>>错误:该文档没有页面.<<<<

Hi,

Im trying to create pdf file using itextsharp so that im using the below code.
im getting the >>>>Error: The document has no pages.<<<<

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=UserDetails.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A2, 7f, 7f, 7f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();



谢谢.



Thanku.

推荐答案

hi
请查看以下链接[
hi
check out the following link[^]


为什么不使用. PdfSharp?它是一个开源,易于使用且非常广泛的库.您可以使用此格式以您自己的格式生成几乎所有类型的pdf.尝试一下,几分钟之内您还将获得很多示例.
请点击以下链接:
http://www.pdfsharp.com/ [
why don''t you use. PdfSharp ? it is an open source, easy to use and very wide library. using this u can generate almost any kind of pdf in your own format. give it a try you will get lots of examples also to start in minutes.
follow this link: http://www.pdfsharp.com/[^]


请参阅这些链接..
http://dotnetcodeshelp.blogspot.com/2010/09/creating- pdf-with-aspnet-on-fly.html [ ^ ]
在ASP.NET中创建PDF文档 [
See these links..
http://dotnetcodeshelp.blogspot.com/2010/09/creating-pdf-with-aspnet-on-fly.html[^]
Creating PDF Documents in ASP.NET[^]


这篇关于pdf在asp.net c#中产生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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