exportToPNG

exports a Gantt chart into the PNG format

void exportToPNG( [object export] );
exportobjectoptional, an object with export settings (see the details)

Example

gantt.exportToPNG();
 
//or
gantt.exportToPNG({
  name: "mygantt.png"
});
 
//or
gantt.exportToPNG({
    name:"mygantt.png",
    header:"<h1>My company</h1>",
    footer:"<h4>Bottom line</h4>",
    locale:"en",
    start:"01-04-2013",
    end:"11-04-2013",
    skin:'terrace',
    data:{ },
    server:"https://myapp.com/myexport/gantt",
    raw:true,
    callback: function(res){
        alert(res.url);
    }
});

Details

This method is defined in the export extension, so you need to activate the export_api plugin. Read the details in the Export to PDF and PNG article.

If you use the Gantt version older than 8.0, you need to include the https://export.dhtmlx.com/gantt/api.js on your page to enable the online export service, e.g.:

<script src="codebase/dhtmlxgantt.js"></script>
<script src="https://export.dhtmlx.com/gantt/api.js"></script>

The exportToPNG method takes as a parameter an object with a number of properties (all of the properties are optional):

Exporting large Gantt by pieces

The maximal sizes of the exported file are 10000х10000.

You can increase one of the sizes, and decrease another one correspondingly via the width/height attributes of the additional_settings property. But if the product of the values of the width and height is greater than 100000000 (10000х10000), the output PNG image will be cropped off.

There is the ability to export the gantt by pieces and obtain them in the archive by using the slice_archive attribute of the additional_settings property of the method:

gantt.exportToPNG({
    server: "https://export.dhtmlx.com/beta/gantt",
    additional_settings:{
        //width: 2000,
        //height: 2000,
        slice_archive: {width: 2000, height: 2000},
        slice_check: true,
    }
});

Related sample: Export into PNG images

You can either define the sizes of the output PNG images via setting the attribute as an object with the width and height options:

slice_archive: {width: 2000, height: 2000}

or you can set the attribute to true. In this case, the exported pieces of the gantt will have default sizes: 1000×1000.

slice_archive: true

Time restrictions

The export service has time restrictions.

If the process takes over than 20 seconds, the export will be canceled and the following error will occur:

Error: Timeout trigger 20 seconds

If several people export Gantt at the same time, the process can take more time than usual. But that's fine because the time which is spent for export request from a specific user is counted separately.

If you need to export large charts, you can use a standalone export module. The export module is provided free of charge if you've obtained Gantt under Commercial, Enterprise or Ultimate license, or you can buy the module separately.

See also
Back to top