Export To Image
By default, the gantt will export to an image with the full grid table and the currently visible timeline in the chart. In export to image, it will prompt you to download the image with the extension of ".png", which you can save to your machine. Gantt can be exported to ".png" and ".jpg" image formats only.
To Export to Image:
|
$ganttElement.data("GanttControl").ExportToImage(); (or) $ganttElement.GanttControl("ExportToImage"); |
You can customize the format in which the image is exported as using the Extension option. 'jpg' and 'png' are the supported formats. 'png' is the default.
Here is the code example:
|
Gantt.ExportToImage({ Title: "fileName", Format: 'jpg'}); (or) Gantt.ExportToImage({ Title: "fileName", Format: 'png'}); |
In some cases, instead of saving the image to machine, you have to send the image to server. Take a look at this topic for more info on this.
Export To PDF
Gantt doesn't have any built in support to export as PDF but it provides a canvas which can be converted as a PDF files using jspdf utility.
Here is an Example.
|
var printOptions = new RadiantQ.Gantt.PrintOptions(); RadiantQ.Gantt.RQPrint($ganttElement.data("GanttControl"), printOptions, afterCanvasGeneratedCallBack/*enabling 'ExportToPDF' option*/); |
The afterCanvasGeneratedCallBack is a method which will provide the Gantt as canvas.
Here is the example code that shows how to convert Gantt canvas to PDF:
|
function afterCanvasGeneratedCallBack(canvasArr) { var doc = new jsPDF('l', 'pt', [canvasArr[0].width, canvasArr[0].height]); for (var i = 0; i < canvasArr.length; i++) { var canvas = canvasArr[i]; var imgData = canvas.toDataURL('image/png'); doc.addImage(imgData, 'png', 0, 0, canvas.width, canvas.height); } doc.save('Gantt.pdf'); // return 'false' to enable PDF option. // return 'true' to continue with default printing. return false; } |
The jspdf.debug.js is placed inside the <Installedolder>/Scripts folder. You can get more information about the jsPDF file in the jsPDF documentation online.
� RadiantQ 2022. All Rights Reserved.