xiaokui

saving images

Recommended Posts

hello tmorsey

 

 

 

sorry but due to other projects which have a hard deadline i had to stop my work on server side swf rendering and cannot work the next to weeks on this issue but i will explain to my approach:

 

 

 

in php it is possible with the win32std extension to call some dll files or to call a command line application on the server. i have found a library called swfToImg that can render swf as image and save it in a jpg file. so i will do the following

 

 

 

1. make a request to the server

 

2. generate xml for the chart

 

3. call the swfToImg library in php with win32std extension and give the xml chart data to it

 

4. the library will generate a image and save it in the webroot of your webserver

 

5. copy the image to a place where you need it with php

 

6. inject the image in a pdf

 

7. send the pdf to the client

 

 

 

one major bug: will only work on windows servers because the swfToImg library is only available in windows..

 

does anybody know an other way??

Share this post


Link to post
Share on other sites

Hi Christian,

Thanks for the advice I am giving this a go.

I am currently stuck on 3. call the swfToImg library in php with win32std extension and give the xml chart data to it

Basically my problem is I want the pdf to be served from a linux server. I do have a windows server but its a few thousand miles away.

So I have installed SWF to image which works from asp on the windows machine.

So in ASP on the windows server I am trying to load up my swf file from my linux server which seems to work. I then load the xml remotely into asp however I am stuck on passing the xml to the swf file.

Swftoimage seems to want it passed in the querystring with the swf object like this:

strUrl ="http://www.X.com/fusiongadgets/Pie3D.swf?dataXML=" & MYXML &""

url = Server.URLencode(strUrl)

response.write url

Set SWFToImage = CreateObject("SWFToImage.SWFToImageObject")

SWFToImage.InputSWFFileName = url

Firstly is dataXML the right variable to use and second we are limited in the querystring by the number of characters so this method won't work on large XML data.

Is there any way you know to overcome these problems?

Thanks

Leon 

Share this post


Link to post
Share on other sites

its good to see that somebody picked up my workaround and is trying to implement it :)

 

 

 

yes you are right you are limited by datalenght when you pass the xml as dataXml in the url. but fusioncharts has also the ability to read out a xml file. to do this you need this url

 

 

 

chart.swf?dataURL=Data.xml

 

 

 

the question is: where do youe have to place the data.xml file to be read out by the swf file?? :) trying is the best idea i think....

 

 

 

ps: because i wasn't able to access all features by the dll file within php i coded a small console application which takes the xml as argument and starts the function contained in the swfToImage dll! i can send it to you if you need id.

Share this post


Link to post
Share on other sites

Thanks I will try it.

My problem is I am requesting the swf remotely and the xml file remotely as I have to due to the windows limitation, and I cant specify a remote url in the field.

I might have to request the remote xml file write it to the server pass it to swftoimage locally etc.

Its quite a long process really to achieve something that needs to be core functionality....

Share this post


Link to post
Share on other sites

At present I am stuck. I have made a copy of the xml file and put it and the swf file with the swftoimg dll just like the example. However when I try and generate the image it is always blank. I have tried capturing upto 5 frames and still they are all blank. Just a white image!

Any ideas?

Share this post


Link to post
Share on other sites

I just found out you cannot use swf to image with XML data unless you purchase the commercial version which is 100 dollars.

I think I might go for it anyway

Share this post


Link to post
Share on other sites

hello

 

 

 

i also found out that i always get white/blank images back. this is because you have to set "animation" property firstly to "0" because then it needs longer to generate the swf.

 

 

 

i make a for for all images in the frame and only save the last image.

 

 

 


// make flash object

               SWFToImage.SWFToImageObjectClass swf = new SWFToImageObjectClass();

               swf.InitLibrary("demo", "demo");

               swf.InputSWFFileName = swfFilename;

               swf.ImageOutputType = TImageOutputType.iotJPG;



               // execute flash

               swf.Execute_Begin();



               // set data xml

               swf.Execute_SetVariable("dataXML", vars);



               for (int i = 0; i < 3; i++)

               {

                   swf.FrameIndex = i;

                   swf.Execute_GetImage();

               }



               swf.SaveToFile(imgFilename);

 

 

 

this code is programmed in c#. its a console application which loads the dll.

Share this post


Link to post
Share on other sites

Hi Thanks I got this working after your help. Turning animation of is key. Also if anyone else is trying this and you run the Franescount and it is -1 it means you probably have a problem with the path to the swf.

Now the main problem is getting dataURL to work as dataxml wont work for most of my charts due to the length of the xml file not fitting in the querystring....

I've tried using a local file, remote file etc but no luck

Any ideas?

Share this post


Link to post
Share on other sites

that means your code is working?? cool :)

 

 

 

you have an asp server running? can you please post your code at asp site because than i can make a console application for windows which can be invoked by php!!!

 

 

 

good to see some people working on the issue ;) i think we have to get a little gift by fusioncharts ;)

Share this post


Link to post
Share on other sites

Hi,

 

 

 

We would be willing to help with any 3rd party licenses/support that you need on this - just drop me an email at pallav [at] infosoftglobal.com

Share this post


Link to post
Share on other sites

ok thanks to the fusioncharts team!!

 

 

 

yesterday evening i had a new idea how we can achieve server side flash rendering. there should be a way to directly connect to the gecko rendering engine or to the webkit engine. or do you know a browser which doesnt make a real windows form but renders the website in the background to make an screenshot of it?

 

 

 

i know from an project where you can submit your website and the site is rendered on different operating systems and different browsers and different screen resolutions. some days later you get all screenshots of it. but i can't remember the name of this webiste!! ....

Share this post


Link to post
Share on other sites
tmorsey (5/27/2008)
Christian,

 

 

 

Have you done any work on the "render image file from swf on the server." issue? I'm using PHP on the server and I also would like to save the JPG file on the server to be used in a PDF. Please update us on your progress - thanks!!!

 

 

 

FusionCharts Development Team, this would be a very desirable feature to add. SaveAs is nice, but saving to a server is something that real applications can use. I see more and more "on the fly" PDF creation out there in financial applications that would benefit from the slick looking charts from your package. The problem is that none of the Flash charting packages out there allow saving images to the server. It seems as though there are ways to do this as demonstrated by the Ruby/Rails developer in this forum and by Christian who says he knows how as well. Please consider adding this feature or at least publish the PHP/server side code to do it in this forum.

 

 

 

Thanks!!

 

 

 

Our Open Laszlo application will be using Fusion Charts for Flex. Our application currently provides for canned reports generated to pdf on the linux server. We will be adding ad-hoc pdf reporting soon. To be able to include these beautiful charts in our [on-the-fly] pdf reports would be quite fine indeed. We would use a feature such as this quite alot.:)

Share this post


Link to post
Share on other sites

Christian,

 

 

 

Do you think creating so many instances of browsers on the server would scale? It could well be 100s or 1000s of instances of even a basic rendering engine that would need to be created on server. While for smaller values it might work well, for larger installations I am not sure how scalable it would be. Would appreciate any feedback from anyone.

Share this post


Link to post
Share on other sites

no i think it wont scale. that is why you have to wait 2 days for feedback at the service that is rendering you website on different resolutions, operating systems and browsers. they have so many jobs to do that you can only process it in a queue.

 

 

 

because of some other problems we didnt had time to make a workaround for the image issue. the pdf export in our application is still very urgent. i think the best way is to have a command line application on the server which can rendr flash and make an image of it. i only know a library which works on windows. does somebody know something that works on other machines too?

 

 

 

we will try to start programming this application in the next 2 weeks... or has somebody a better idea?? :)

Share this post


Link to post
Share on other sites

thanks for your quick response. i already found it in the docs.

 

unfortunately we cant use it because we have some background cronjobs which are generating reports in pdf format and send them to some users. so we have no chance to render it in a browser...

Share this post


Link to post
Share on other sites

You are most welcome.

Unfortunately, at the time, there is no way to achieve what you require automatically. For the image to be captured, it must be rendered first. Do let us know if you devise a workaround! :)

Share this post


Link to post
Share on other sites
Dhruva (4/14/2009)
Hello,

Could you please go to http://www.fusioncharts.com/docs/ and check the Exporting as Image/PDF section?

Before that, please upgrade to v3.1.1 of FusionCharts, which is available freely at http://www.fusioncharts.com/PUC

I hope this helps! :)

Hi,

We are now upgrading to FusionCharts 3.1.0.

Since we upgraded, the "save as image" feature does not work.

I read today the documentation of the charts export in FusionCharts 3.1.0, and my question is:

Is the way to implement the server side chart export to JPEG/PDF is by using FusionCharts export handlers?

How can this be done? Do we have to take the "fcexporter.jar" we downloaded, put it in our project and user its classes to generate the JPEG/PDF of the chart?

Thanks!

Liza

Share this post


Link to post
Share on other sites

I love the charts generated from FusionCharts. I tested it a year ago and now I'm back to find out if it can support my particular case for generating images.

 

 

 

I have a large Excel file that generates about 50 different charts that eventually get fed into a Word document for a report I produce every quarter. Before, it was simply too slow for me to feed that data into code, display the chart via Flash in my browser, click and save the file, and then import it into my Word file. Is there now a way to do this more quickly? I realize, based on the different product types available, that FusionCharts is meant to be more web friendly and not tailored for my case. But the fact is the beautiful charts from the product are perfect for sprucing up my not Web 2.0 reports. Any help or insight would be much appreciated.

Share this post


Link to post
Share on other sites

Hi

Yes, these beautiful charts can be saved as image or pdf from your jsp pages by just using the fcexporter.jar and a few jsps provided in the download package.

You can either save the charts on the server or download them.

Hope this helps.

Share this post


Link to post
Share on other sites

Well, that was my point: I'm aware I can save the charts from a jsp rendering and that's what I'd like to avoid. Is there any way to generate charts within Excel? How about a tool that can automatically generate the jsp from an input file (XML, CSV, whatever), render it, and save as image? To reiterate, I have to generate many images and doing it one by one by hand isn't an option.

Share this post


Link to post
Share on other sites

I try to create chart with image downloadable option using jsp.The chart can display and download successfully, but the downloaded image cannot open with image viewer program.

Got message "No preview available".I use the FusionCharts v3.1,please help me.

Share this post


Link to post
Share on other sites

I am able to get the image with the xml you have provided and preview it too.

What is the size of the downloaded/saved file? ( is it 0KB)

What is the extension ( JPG or PNG or GIF ) ?

regards

Srividya

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now