如何将当前的ASPX页面导出为PDF

如何将当前的ASPX页面导出为PDF

问题描述:

我有一个使用gridviews和html元素组合的网页来创建报告。我想给用户一个选择点击,它会导出到PDF。我不希望在服务器上创建pdf,因为这需要我编写另一个进程来清理文件。

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.

理想情况下,我希望当前页面打开一个呈现PDF的新页面,并提示用户保存/打开它。

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.

我看过iTextSharp,并且有兴趣使用它,如果我不需要指定每个元素。如果有方法来指定一个面板及其所有内容或替代方案,我也可以这样做。

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.

谢谢!

如果您可以说服用户安装PDF打印机,如 CutePDf 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