Failing to export the gantt on multiples PDF pages

Hello!
I’m having a gantt chat of this size : [png in dropbox]
I tried to make the pdf split it in multiple pages in all possible ways, I tried all these settings parameters

ganttInstance.exportToPDF({
                width: 210,
                height: 297,
                merge_pages: false,
                format: "A4",
                landscape: true,
                slice_archive: { width: 210, height: 297 },
             });

But I got a full gantt in only one page dropbox pdf

What I did wrong ?

(https://www.dropbox.com/scl/fi/1trez9aiaaxpf1f2isnlz/gantt-8.png?rlkey=7tca6urs8j0shrw5kmfyxuhpf&st=ztlbc9x2&dl=0)

Hello Ahmed,
You are using the Gantt API the wrong way. All these options should be specified inside the additional_parameter object of the export function:

ganttInstance.exportToPDF({
    additional_settings: {
        width: 210,
        height: 297,
        merge_pages: false,
        format: "A4",
        landscape: true,
        slice_archive: { width: 210, height: 297 },
    }
});

The slice_archive option is available only in the exportToPNG function, other options are available only in the exportToPDF function:
https://docs.dhtmlx.com/gantt/desktop__export.html#:~:text=(object)%20an%20object%20with%20additional%20settings%20for%20the%20exportToPDF()%20method.%20The%20object%20can%20contain%20the%20following%20attributes%3A

https://docs.dhtmlx.com/gantt/api__gantt_exporttopdf.html#:~:text=(object)%20an%20object%20with%20additional%20settings.%20The%20object%20can%20contain%20the%20following%20attributes%3A

https://docs.dhtmlx.com/gantt/api__gantt_exporttopng.html#:~:text=(object)%20an%20object%20with%20additional%20settings.%20The%20object%20can%20contain%20the%20following%20attributes%3A

When you specify the format function, the width and height parameters are ignored (and they are specified in pixels, not in millimeters).

Also, when the merge_pages parameter is false, you can only see the content that fits the format sizes. Other parts of Gantt are not included. You can read about it in the following article:
https://docs.dhtmlx.com/gantt/api__gantt_exporttopdf.html#multipageexport

When the merge_pages parameter is enabled, you can see all the content, but the online export server is limited by the 20-second limit, so, to see larger charts, you need to use the standalone export module.

You can experiment with that in the following snippet:
https://snippet.dhtmlx.com/dts7eihd

1 Like

Ok , thanks @ramil , now it works better for the PDF export. I got it in multiples pages.
But it didn’t work for the PNG. I still have it in one page

           ganttInstance.exportToPNG({
              additional_settings: {
                merge_pages: false,
                format: "A4",
                landscape: true,
              },
            });

I tried merge_pages with all possible values or even without passing it at all but it’s still not working.
Why ?

Hello Ahmed,
PDF is a document file, so it may have pages. PNG is a picture, it cannot have multiple pages. So, it should be expected that the exportToPNG function doesn’t have the merge_pages, format, and landscape parameters in the additional_settings object. But you can use the slice_archive option that allows to create multiple parts of PNG images of the chart:
https://docs.dhtmlx.com/gantt/api__gantt_exporttopng.html#:~:text=Exporting%20large%20Gantt%20by%20pieces

Please note that creating PNG images requires more RAM and time. So, if you use the online export server, you can export only the smaller charts comparing with the exportToPDF function.
You can experiment with that in the following snippet: