pdf在asp.net c#中产生错误

编程入门 行业动态 更新时间:2024-10-19 13:32:17
本文介绍了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#中产生错误

本文发布于:2023-11-02 17:13:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1552963.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   pdf   asp   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!