如何将当前 ASPX 页面导出为 PDF
我有一个网页,它使用 gridviews 和 html 元素的组合来创建报告。我想给用户一个点击选项,它将导出为 pdf。我不想在服务器上创建 pdf,因为这需要我编写另一个进程来清理文件。
最理想的是,我希望当前页面打开一个新页面,该页面呈现 pdf 并提示用户保存/打开它。
我研究过 iTextSharp,并且如果不必指定每个元素,我有兴趣使用它。如果有一种方法可以指定一个面板及其所有内容或替代方案,我也对此持开放态度。
谢谢!
I have a web page that uses a combination of gridviews and html elements to create a report. I would like to give the user an option to click and it will export to a pdf. I would prefer not to create the pdf on the server as that requires me to write another process to clean up files.
Optimally, I'd like the current page to open a new page that renders the pdf and prompts the user to save it/open it.
I've looked at iTextSharp and am interested in using it if I don't have to specify every element. If there is a way to specify a panel and all of it's contents or an alternative, I'm open to that too.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你能说服用户安装一个 PDF 打印机,比如 CutePDf< /a> 或 Foxit PDF Creator
This would be way way easy if you could convince the user to install a PDF Printer like CutePDf or Foxit PDF Creator
我知道这是一个老问题,但我的公司做了与您需要的非常相似的事情。我们使用 ExpertPDF 将 html 转换为 pdf 并执行以下操作获取html。务必启用 EnableEventValidation="false",因为将 html 发送回服务器存在安全风险。
ASPX
您还必须发送对 css 样式表和
CS 的引用
I know this is an old question but my company does something very similar to what you need. We use ExpertPDF to convert the html to pdf and do the following to get the html. It is important that you turn EnableEventValidation="false" as sending back html to the server is a security risk.
ASPX
You will also have to send a reference to your css style sheet as well
CS