繁体   English   中英

将asp.net页面导出为pdf问题

[英]Export asp.net page to pdf issue

要将页面导出到Pdf,我从Google找到了代码。 导出后,我将其他信息获取到pdf文件中。

 Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=TestPage.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.A4, 10f, 10f, 100f, 0f);
            HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
            PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
            pdfDoc.Open();
            htmlparser.Parse(sr);
            pdfDoc.Close();
            Response.Write(pdfDoc);                
            Response.Flush();

以下附加信息显示在底部的我的pdf文件中。

// var theForm = document.forms ['form1']; 如果(!theForm){theForm = document.form1; }函数__doPostBack(eventTarget,eventArgument){if(!theForm.onsubmit ||(theForm.onsubmit()!= false)){theForm .__ EVENTTARGET.value = eventTarget; theForm .__ EVENTARGUMENT.value = eventArgument; theForm.submit(); }} //

如何在将页面导出到Pdf时摆脱上面的其他信息?

任何形式的提示或示例代码将不胜感激。

我有同样的问题。 尝试从aspx文件中的asp网格视图中删除AllowPaging =“ true”和AllowSorting =“ true”。 我的问题解决了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM