CDekker Report post Posted April 9, 2008 Currently we are running a reporting system written in Ruby on Rails with one or more FusionCharts in it depending on the type of the report. Now we recently decided to offer the reports in a printable format and have chosen for a PDF solution where we can convert the HTML report with the chart to a WYSIWYG (What you see is what you get) layout to print and email. The only problem there though was the rendering of the FusionChart to PDF. Now since the chart itself is being rendered on the clientside it is tricky to make a snapshot of it and place it in the PDF which is generated serverside. It is not an option to use the 'new' built in 'save as image' flash option since that would require user intervention. I will explain how the report is rendered. In Ruby we have a report object with all the relevant data in it, as well as the XML stream to the chart. The XML and a reference to the SWF are being placed in tags, and finally served with the rest of the textual data to the browser as one HTML stream, which then is rendered on the client. The chart is drawn by the client flash player. Now I need some way to either render the FusionChart serverside and make a screenshot from it somehow, or use the XML feed (which basically has just values of the bars in the chart, no drawing information which is in the swf itself) to generate a similar image as the client will eventually see. The only specific ruby implementation I have found is located here on this forum: http://www.fusioncharts.com/forum/Topic724-28-3.aspx yet this does not comply with my wishes, as it doesn't draw it as WYSIWYG but some crude colored bars and the needed RubyInline works very poorly and buggy on Windows machines. Besides is it unclear to me how they implemented this (how the image is requested) and where the input is coming from (it seems like it wants an array with color values for all pixels, where do I get that?) Currently I am clueless where to start on this subject as all search results point to some clientside initiation which is not really applicable for my Ruby implementation. I need to be able to serve 1 dynamically generated image to the PDF renderer. How does one go around doing this? I guess I am not the first one to want to render a FusionChart to a PDF and need to convert it to an image serverside yet so little information about it. Thanks for the info up front! Share this post Link to post Share on other sites
Pallav Report post Posted April 15, 2008 Hi, FusionCharts is essentially a Flash movie that reads XML data at client side and then renders it as a chart. As such, you cannot directly generate a server-side image of the chart. The only way would be to have the charts rendered at client side and then post the bitmap data to server (either using user interaction or JS method) and then save it as an image for inclusion in PDF. Share this post Link to post Share on other sites
Palmade Report post Posted June 9, 2008 I'm very curious if you already found a solution ? We're also trying to generate the pdf with fusioncharts for our RoR app. Didn't find any solution yet .... Thank you! Share this post Link to post Share on other sites
milo Report post Posted July 18, 2008 FusionCharts is essentially a Flash movie that reads XML data at client side and then renders it as a chart. As such, you cannot directly generate a server-side image of the chart. The only way would be to have the charts rendered at client side and then post the bitmap data to server (either using user interaction or JS method) and then save it as an image for inclusion in PDF. Base on the suggestion above, I was able to send the bitmap image to the server (running ruby on rails), however, the problem is I need to put two images in the resulting pdf. The situation is like this, I have 2 graphs on my page, a line chart and a pie chart. I need to print a pdf containing both charts. My plan was to trigger a javascript that will initiate the printing of the line chart, once completed, the server side code will return a javascript that will initiate the printing of the pie chart, and lastly the server side code will return a javascript that will render the pdf containing both charts. Unfortunately, their is no way to return a javascript from the server code that was invoked by fusionchart. Once saveAsImage calls the server, it just redirects to another page which is not my intention in the first place. Is there a way to do this? Share this post Link to post Share on other sites
Pallav Report post Posted July 21, 2008 One way could be to modify the server side script to not return the image. Instead it can save it on the local filesystem and the other file can check if both images have been generated. Share this post Link to post Share on other sites
dougboude Report post Posted August 2, 2008 Hi there. My challenge wasn't exactly like yours, but I would say very similar, the only difference being that I wasn't mandated to produce PDFs, but rather simply print a page that contained several charts. I did find a way to do it, so wanted to come back here and share what I learned. The solution, at least the way I found to do it, is somewhat complex and involves several steps, but in the end it worked well for me. I took the time to do a very detailed blog post about it, and you can read it at http://www.dougboude.com/blog/1/2008/08/Printing-Multiple-FusionCharts-ChartsMaps.cfm I built my solution using Coldfusion and an MVC framework called Model-Glue, but I tried to keep the explanation as language agnostic as possible. I also did take the time to convert FusionCharts' CFM image processing page into a CFC component. I made all of my code available for download and dissection in the blog post. FusionCharts team, I do believe that the ability to print rendered charts is a need that many people frequently have. If there is anything you can put on your "to do" list that will make this process less painful, it would be very helpful! Such as, allow javascript to be passed to the printURL attribute, allow the ability to designate a popup window for the printURL action (it appears to be hardcoded to _self currently). Thanks for a great product! Share this post Link to post Share on other sites
Dhruva Report post Posted April 10, 2009 Hello everyone, I'm bumping this thread just to bring to notice that PDF generation is now possible in FusionCharts products! Cheers! Share this post Link to post Share on other sites