Sign in to follow this  
mokalovesoulmate

Export chart to JPG then throw it into PDF

Recommended Posts

Hello,

 

 

 

I have a problem to export charts and pie to JPG and render it directly to PDF.

 

 

 

I have a single layout page contains 4 angular chart and 1 pie chart, and a button to generate the page into PDF.

 

 

 

The library I am using to convert HTML to PDF is FPDF. FPDF can render the HTML script into PDF with same layout as the webpage (if you write the same code).

 

 

 

FPDF can also insert the JPG image to be rendered on PDF file.

 

 

 

Now I want to automatically export that 4 angluar and 1 pie to 4 JPG of angular and 1 JPG to a folder and let the FPDF render it as PDF.

 

 

 

The problem is, to the point, I dont understand how to make them automatically export (I dont need to right click > export as blabla at the chart) to JPG then system put the generated JPG file into a folder and redirect the browser to load the PHP page that contains FPDF code, to render to PDF file within HTML and JPG file generated by the chart. :)

 

 

 

Any helps would be appreciated.

 

 

 

Thanks!

Share this post


Link to post
Share on other sites
Guest Rajroop

Heylo,

 

 

 

Attached is a sample for 'automatic export' for the rendered chart, without having to click on the chart.

 

 

 

Please let us know if it comes of use to you. :)

forum.zip

Share this post


Link to post
Share on other sites

Hello,

 

 

 

Sorry, I've just read the forum back and just almost 50% solving my problem :)

 

 

 

Ok, new problem.

 

 

 

I've been able to export all charts into JPG file in the specified directory. Now, how to change the filenaming schema of JPG exporting (because I did not find it on the documentation). For example I want the export filename become user1_221009_16-36-chart1.jpg, user1_221009_16-36-chart2.jpg, user1_221009_16-36-chart3.jpg, user1_221009_16-36-chart4.jpg, user1_221009_16-36-pie1.jpg.

 

 

 

And then after exporting process already done and the images has been on the specified folder, the page automatically redirect to a page that will render to PDF but the page which will render PDF must remember the filename and path previously generated by the export button.

 

 

 

Any suggestion and help will be appreciated....

 

 

 

Thanks!

Share this post


Link to post
Share on other sites

Hello,

 

 

 

Wow, still no reply then. I've been 90% troubleshoot my problem.

 

 

 

Now I will simplify my problem so it will easy to answer.

 

 

 

I have a multiple charts, then I want to save it into the server's disk, but I dont want it combined (like the sample provided before this post) So I want each chart exported as single JPG, not combined JPG.

 

 

 

I am using FusionWidgets Developer Edition.

 

 

 

Thanks!

Share this post


Link to post
Share on other sites

hi mokalovesoulmate

 

please add this js function in your page. this will export all the chart automaticaly as indivijual image

 

 

 

function FC_Rendered(DomID) {

 

var chartObject = getChartFromId(DomID);

 

chartObject.exportChart();

 

}

Share this post


Link to post
Share on other sites

Hi, thanks for the reply.

 

 

 

Another problem ... hehehe.

 

 

 

Each script given in this thread, is automatically export the chart on each page load.

 

 

 

How to make the script active when something clicked (not on page load)?

 

 

 

Thanks!

Share this post


Link to post
Share on other sites

Hi,

 

 

 

Could you please take these steps?

 

 

 

1. create an array containing DOMId s of all charts present in the page.

 

 

 

2. in FC_Rendered set a flag for each id so that you can check whether all charts have been loaded.

 

 

 

3. Make a HTML element with click event where you iterate through the array and use the exportChart() function called to each chart present in the page/array.

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
Sign in to follow this