fix(ui): fix bugreport pdf gen

This commit is contained in:
nick-delirium 2023-01-27 13:25:55 +01:00
parent e96e84b98d
commit 757d2ca77a

View file

@ -119,21 +119,20 @@ function BugReportModal({ hideModal, session, width, height, account, xrayProps,
}).then((canvas) => {
const imgData = canvas.toDataURL('img/png');
var imgWidth = 200;
var pageHeight = 295;
var imgHeight = (canvas.height * imgWidth) / canvas.width;
var heightLeft = imgHeight;
var position = 0;
let imgWidth = 200;
let pageHeight = 295;
let imgHeight = (canvas.height * imgWidth) / canvas.width;
let heightLeft = imgHeight - pageHeight;
let position = 0;
doc.addImage(imgData, 'PNG', 5, 5, imgWidth, imgHeight);
doc.addImage('/assets/img/report-head.png', 'png', 210/2 - 40/2, 2, 45, 5);
heightLeft -= pageHeight - 7;
if (position === 0 && heightLeft === 0) doc.addImage('/assets/img/report-head.png', 'png', 210/2 - 40/2, pageHeight - 5, 45, 5);
while (heightLeft >= 0) {
position = heightLeft - imgHeight + 10;
position = heightLeft - imgHeight;
doc.addPage();
doc.addImage(imgData, 'PNG', 5, position, imgWidth, imgHeight);
doc.addImage('/assets/img/report-head.png', 'png', 210/2 - 40/2, pageHeight - 5, 45, 5);
@ -141,7 +140,6 @@ function BugReportModal({ hideModal, session, width, height, account, xrayProps,
}
doc.link(5, 295 - Math.abs(heightLeft) - 25, 200, 30, { url: sessionUrl });
if (position === 0) doc.addImage('/assets/img/report-head.png', 'png', 210/2 - 40/2, pageHeight - 5, 45, 5);
doc.save('Bug Report: ' + sessionId + '.pdf');
setRendering(false);