Hi,
I read this article
https://www.aspsnippets.com/Articles/Export-ASPNet-Chart-Control-to-PDF-Document-using-iTextSharp-Library.aspx
The question is it is working only if first to export by itextsharp I reload data?
So to export I need to execute the query two times, one when the user have a search and other if the user need to export?
Is there any workaround?
then
Protected Sub btnExportPDF_Click(ByVal sender As Object, ByVal e As EventArgs)
ReloadDATA() 'Else it doesnt work!
Dim pdfDoc As Document = New Document(PageSize.A4.Rotate, 10.0!, 10.0!, 10.0!, 10.0!)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
Dim stream As MemoryStream = New MemoryStream
Chart1.SaveImage(stream, ChartImageFormat.Png)
Dim chartImage As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(stream.GetBuffer)
chartImage.ScalePercent(75.0!)
pdfDoc.Add(chartImage)
pdfDoc.Close()
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=Chart.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Write(pdfDoc)
Response.End()
End Sub