ASP.NET页面图像或PDF [英] ASP.NET page to image or PDF

查看:115
本文介绍了ASP.NET页面图像或PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的ASP.NET页面:

I have an ASP.NET page like this:

http://farm4.static.flickr.com/3631/3690714302_c17b259863.jpg

我的表是的GridView 有的标签,任何人都可以告诉我如何创建一个按钮来转换我的网页图像或PDF文件并将其保存到桌面上。

My table is Gridview and some Label, anybody can tell me how to create a button to convert my page to image or PDF file and save it to desktop.

推荐答案

上使用iTextSharp的到您的网页转换为PDF。
它看起来很漂亮。
只需下载该DLL文件,并添加引用您的应用程序。
然后在点击链接给编码如下:

Hai use iTextSharp to convert your webpage to pdf. It looks very nice. Just download the dll file and add reference to your application. Then in button click give the coding as follows.

Response.ClearHeaders()
    Response.ContentType = "application/pdf"
    Response.AddHeader("content-disposition", attachment; filename=jaison.pdf")
    Response.Cache.SetCacheability(HttpCacheability.NoCache)
    Dim sw As New StringWriter()
    Dim hw As New HtmlTextWriter(sw)
    Me.Page.RenderControl(hw)
    Dim sr As New StringReader(sw.ToString())
    Dim pdfDoc As New Document(iTextSharp.text.PageSize.A2, 10, 10, 10, 10)

    Dim htmlparser As New HTMLWorker(pdfDoc)
    PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
    pdfDoc.Open()
    htmlparser.Parse(sr)
    pdfDoc.Close()
    Response.Write(pdfDoc)
    Response.End()

这肯定会帮助你。

Surely this will help you.

所有最好的...

这篇关于ASP.NET页面图像或PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆