* [perf story #59018] Export to png for gantt wg.
This commit is contained in:
+36
-16
@@ -122,26 +122,46 @@ function drawGanttToCanvas(exportType, successCallback, errorCallback)
|
||||
afterFinish(canvas);
|
||||
if(errorCallback) errorCallback('Cannot convert image to blob.');
|
||||
};
|
||||
let width = canvas.width;
|
||||
let height = canvas.height;
|
||||
getRemoteScript(jsRoot + 'js/pdfjs/min.js', function()
|
||||
if(isExportPDF)
|
||||
{
|
||||
updateProgress(0.8);
|
||||
let pdf = new jsPDF(
|
||||
let width = canvas.width;
|
||||
let height = canvas.height;
|
||||
getRemoteScript(jsRoot + 'js/pdfjs/min.js', function()
|
||||
{
|
||||
format: [width, height],
|
||||
unit: 'px',
|
||||
orientation: width > height ? 'l' : 'p'
|
||||
let pdf = new jsPDF(
|
||||
{
|
||||
format: [width, height],
|
||||
unit: 'px',
|
||||
orientation: width > height ? 'l' : 'p'
|
||||
});
|
||||
pdf.addImage(canvas, 0, 0, pdf.internal.pageSize.getWidth(), pdf.internal.pageSize.getHeight());
|
||||
pdf.save(fileName + '.pdf');
|
||||
if(successCallback) successCallback(pdf);
|
||||
afterFinish();
|
||||
}, function(error)
|
||||
{
|
||||
afterFinish(canvas);
|
||||
if(errorCallback) errorCallback(error);
|
||||
});
|
||||
pdf.addImage(canvas, 0, 0, pdf.internal.pageSize.getWidth(), pdf.internal.pageSize.getHeight());
|
||||
pdf.save(fileName + '.pdf');
|
||||
if(successCallback) successCallback(pdf);
|
||||
afterFinish();
|
||||
}, function(error)
|
||||
}
|
||||
else
|
||||
{
|
||||
afterFinish(canvas);
|
||||
if(errorCallback) errorCallback(error);
|
||||
});
|
||||
canvas.toBlob(function(blob)
|
||||
{
|
||||
let imageUrl = URL.createObjectURL(blob);
|
||||
if(navigator.msSaveBlob)
|
||||
{
|
||||
navigator.msSaveOrOpenBlob(blob, fileName + '.png');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#mainContent').append('<a id="ganttDownload" style="display:none;" download="' + fileName + '.png" target="_blank" href="' + imageUrl + '"></a>');
|
||||
$('#mainContent #ganttDownload')[0].click();
|
||||
}
|
||||
if(successCallback) successCallback(imageUrl);
|
||||
afterFinish(canvas);
|
||||
});
|
||||
}
|
||||
}).catch(function(error)
|
||||
{
|
||||
afterFinish();
|
||||
|
||||
Reference in New Issue
Block a user