Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. Imports iTextSharp.text
  2. Imports System.IO
  3. Imports iTextSharp.text.html.simpleparser
  4. Imports iTextSharp.text.pdf
  5.  
  6. Protected Sub btnExport_Click(sender As Object, e As EventArgs)
  7. Response.ContentType = "application/pdf"
  8. Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf")
  9. Response.Cache.SetCacheability(HttpCacheability.NoCache)
  10. Dim sw As New StringWriter()
  11. Dim hw As New HtmlTextWriter(sw)
  12. Me.Page.RenderControl(hw)
  13. Dim sr As New StringReader(sw.ToString())
  14. Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 100.0F, 0.0F)
  15. Dim htmlparser As New HTMLWorker(pdfDoc)
  16. PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
  17. pdfDoc.Open()
  18. htmlparser.Parse(sr)
  19. pdfDoc.Close()
  20. Response.Write(pdfDoc)
  21. Response.[End]()
  22. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement