简体   繁体   中英

Highcharts Export Chart To PDF on The Fly Using TCPDF

Can you please let me now how I can export Highchart's chart to Custom PDF on the the fly (without saving the chart on the server). I already Installed the TCPDF and having the chart running (For example at this example ).

$(function () {
        $('#container').highcharts({
            chart: {
                type: 'line'
            },
            title: {
                text: 'Monthly Average Temperature'
            },
            subtitle: {
                text: 'Source: WorldClimate.com'
            },
            xAxis: {
                categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
            },
            yAxis: {
                title: {
                    text: 'Temperature (°C)'
                }
            },
            plotOptions: {
                line: {
                    dataLabels: {
                        enabled: true
                    },
                    enableMouseTracking: false
                }
            },
            series: [{
                name: 'Tokyo',
                data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
            }, {
                name: 'London',
                data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
            }]
        });
    });

Your question is conceptually very wide and as the answer to it involves the use of many other technologies so it is not possible to incorporate all the knowledge my answer. However I have tried to guide to follow certain necessary steps to achieve your goal. Below are the steps:

Firstly, you have to find out how to convert highcharts graph in to an image that could be saved on your server.

For this you can refer the links below:

After you get the image of charts saved on your server, you can use TCPDF library to generate a PDF by adding that image into it and download the file to the user.

For this refer the link:

Hope that helps !!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM