本文介绍了pdf在asp 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.尝试一下,几分钟之内您还将获得很多示例. 请点击以下链接: www.pdfsharp/ [ ^ ] 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: www.pdfsharp/[^]
请参阅这些链接.. dotnetcodeshelp.blogspot/2010/09/creating- pdf-with-aspnet-on-fly.html [ ^ ] 在ASP.NET中创建PDF文档 [ ^ ] See these links.. dotnetcodeshelp.blogspot/2010/09/creating-pdf-with-aspnet-on-fly.html[^] Creating PDF Documents in ASP.NET[^]
更多推荐
pdf在asp.net c#中产生错误
发布评论