我有一個ASP.NET頁面是這樣的:ASP.NET頁面圖片或PDF
http://farm4.static.flickr.com/3631/3690714302_c17b259863.jpg
我的表是Gridview
有的Label
,任何人都可以告訴我如何創建一個按鈕來轉換我頁面轉換爲圖像或PDF文件並保存到桌面。
我有一個ASP.NET頁面是這樣的:ASP.NET頁面圖片或PDF
http://farm4.static.flickr.com/3631/3690714302_c17b259863.jpg
我的表是Gridview
有的Label
,任何人都可以告訴我如何創建一個按鈕來轉換我頁面轉換爲圖像或PDF文件並保存到桌面。
它可以通過後端代碼將HTML渲染爲內存Graphic對象,然後將返回的結果位圖或通過PDF打印機(在服務器上)打印頁面,然後捕獲結果來完成。
Javascript,no。
或谷歌「在線轉換html pdf」並使用其中一項服務。
Hai使用iTextSharp將您的網頁轉換爲pdf。 它看起來非常好。 只需下載該dll文件並添加引用到您的應用程序。 然後在按鈕中單擊按如下所示給出編碼。
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()
當然這段代碼會幫助你。
一切順利!
重複http://stackoverflow.com/questions/280817/how-to-convert-html-web-page-to-image-format-in-asp-net-web-application和許多其他許多人。請先搜索。 – 2009-07-05 16:07:32