 |
|
ผมใช้ code การ export pdf จากเว็ปนี้ครับ https://www.aspsnippets.com/Articles/Export-Paging-enabled-Gridview-to-PDF-with-Formatting-using-iTextSharp-in-ASPNet.aspx
ปัญหาผมคือ มันไม่รู้จัก 3 บรรทัดนี้ครับ ผม import iTextSharp ตามเขาแต่เหมือนมันไม่รู้จักเลยครับ
Code (VB.NET)
Dim pdfDoc As New Document(PageSize.A2, 10.0F, 10.0F, 10.0F, 0.0F)
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
ผมติดแค่ตรงนี้้ครับ ผมจะแก้ปัญหายังไงครับ ไม่อยากใช้ crystal report ครับเนื่องจากมันช้าครับ ถ้าข้อมูลเยอะ
Code (VB.NET)
Protected Sub ExportToPDF(sender As Object, e As EventArgs)
Using sw As New StringWriter()
Using hw As New HtmlTextWriter(sw)
'To Export all pages
GridView1.AllowPaging = False
Me.BindGrid()
GridView1.RenderControl(hw)
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A2, 10.0F, 10.0F, 10.0F, 0.0F)
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
htmlparser.Parse(sr)
pdfDoc.Close()
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Write(pdfDoc)
Response.[End]()
End Using
End Using
End Sub

Tag : .NET, PDF, VS 2008 (.NET 3.x)
|
|
 |
 |
 |
 |
Date :
2019-06-11 16:27:38 |
By :
bankguszo |
View :
1109 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |