i have several charts in my extjs4application dashboard.. i want to generate a pdf report using the images of those charts for that i use iTextSharp
is there a way to get the images from the charts in order to include them in my report?
the ideal for me is to use it like this with itextsharp
MyImageStream = new MemoryStream();
myChart.SaveImage(MyImageStream);
my chart would be the chart object
i asked around in the forums they told me i would generate and render my chart at client (already done) and then i would get the svg, send it to the server and server would use it to generate the pdf... but i dont know how to work with svg neither how to send it to server
EDIT
im trying to use wkhtmltoimage to save my chart into image
but its not working whan i specify a mapPath to my .aspx
but it works fine if i specify a website url or localhost path (see htem in comment)
by doesnt work i mean no error but no png created!
my code:
var url = HttpContext.Current.Server.MapPath("~/chartImage.aspx");//dosnt work
//works : // "google.com"; //"localhost/chartImage.aspx";//
var fileName = " pie13.png ";
var wkhtmlDir = HttpContext.Current.Server.MapPath("~/wkhtmltopdf/pdf/");//"C:\\Program Files\\wkhtmltopdf\\";
var wkhtml = HttpContext.Current.Server.MapPath("~/wkhtmltopdf/wkhtmltoimage.exe");//"C:\\Program Files\\wkhtmltopdf\\wkhtmltopdf.exe";
var p = new Process();
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = wkhtml;
p.StartInfo.WorkingDirectory = wkhtmlDir;
string switches = "";
//switches += "--print-media-type ";
//switches += "--margin-top 10mm --margin-bottom 10mm --margin-right 10mm --margin-left 10mm ";
//switches += "--page-size Letter ";
p.StartInfo.Arguments = switches + " " + url + " " + fileName;
p.Start();
thanks in advance
Use wkhtmltopdf package (http://code.google.com/p/wkhtmltopdf/) to convert a web page with your charts into a pdf file and then let users download that pdf. In order to do that you need to run wkhtmltopdf server-side (pay attention to authentication/user impersonation). Since wkhtmltopdf is based on Safari it should work with extjs without problems.
Ok, here's a revised version after reading your comment above. Ext JS is a client side library so you need to run it in a browser to get your charts and this can't be changed. If you really need to get these charts on the server then you must resort to some more or less dirty hacks. One of them would be:
But in this case I'd rather re-think the choice of tools or the way reports are generated.
I am researching about this, I think you first have to convert your chart into a picture and then use a PDF generator library and include this picture on it. To convert chart to picture: http://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/charts/Area.js
To generate PDF on c# if you are using it on server side it could be pdfsharp or itext