PDA

View Full Version : Export Chart to PDF in extjs4.1 client side



Jeegnesh
27 May 2013, 8:52 PM
Is any code or package available for export the chart(gauge,column) to PDF at client side. bcoz my all the chart is created at client side and i need to export as pdf,but all web forum says that it's only achieve by server side. my extjs version is 4.1 and i am using vb.net as monogramming language.
thanks in advance!

evant
27 May 2013, 9:31 PM
But all web forum says that it's only achieve by server side


Is correct. You might want to look at the sample for SVG exporting, it sends an SVG string to the server and expects an image response. You could probably do a similar thing by either:

a) svg -> pdf
b) svg -> image -> pdf

As for how you achieve a or b, that's outside the scope of this forum.

Jeegnesh
28 May 2013, 10:58 PM
Now see what i done...

<javascript>
Ext.fly('ctl00_RPTHtml').dom.value = ""


var srcurl = 'data.aspx?M=getHTMLToPdf'

form = Ext.get('form2').dom

Ext.fly('ctl00_RPTHtml').dom.value = window.encodeURI(Ext.get(eval(result)[0].columnLineConfig.divToRender).dom.innerHTML);


form.action = srcurl;
form.submit();

</javasript>

and

getHTMLtoPDF:

Dim pdfDocument As PdfDocument.Document = Nothing
Dim pdfConverter As PdfConverter = New PdfConverter()
Dim pdfBytes As Byte() = Nothing


Dim strHtml As String = ""
Dim htmlreport As String = ""
Dim ReportFileName As String = ""
Dim Response_1 As HttpResponse = Me.Response


htmlreport = Me.Request.Form.Item("ctl00$RPTHtml").ToString()
htmlreport = HttpUtility.UrlDecode(htmlreport)


Response_1.Clear()
Response_1.Buffer = True
Response_1.ClearContent()
Response_1.ClearHeaders()


ReportFileName = GetReportName() + ".pdf"


pdfConverter = New Winnovative.WnvHtmlConvert.PdfConverter()


pdfConverter.AvoidImageBreak = True
pdfConverter.AvoidTextBreak = True
pdfConverter.TruncateOutOfBoundsText = True
pdfConverter.LicenseKey = "7MfezN3M3MzbwtzM393C3d7C1dXV1Q=="
pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4
pdfConverter.PdfDocumentOptions.StretchToFit = True


pdfBytes = pdfConverter.GetPdfBytesFromHtmlString(htmlreport)


Response_1.AddHeader("Content-type", "application/pdf")
Response_1.AddHeader("Content-Disposition", "attachment; filename=" + ReportFileName)


Response_1.BinaryWrite(pdfBytes)
Response_1.Flush()
Response_1.End()
-----------------------------------------------------------------------------
i get this one why this happening. something mistake in select innerhtml


44064

Jeegnesh
13 Jun 2013, 4:21 AM
bcoz i forgot to include the "ext-all.css" file
just see how i include
Dim objReader As New System.IO.StreamReader(Server.MapPath("App_Themes/ext-all.css"))
Dim a As String = objReader.ReadToEnd
htmlreport = "<html><head><style type=""text/css"">" + a + "</style></head><body>" + htmlreport + "</body></html>"

problem solved

NgurahJanuar
23 Mar 2017, 7:20 PM
Can I get you're example on jsfiddle.net? I'm looking forward for this feauture
*Btw, can I use this method in ExtJS 4.2?

Thanks in advance