From d84a9e6608c08da02a7068a19542fa302b690073 Mon Sep 17 00:00:00 2001 From: Aziz <119948730+aziz-access@users.noreply.github.com> Date: Mon, 11 Sep 2023 19:57:32 +0200 Subject: [PATCH] fix(geo): delete map legend after the printing from the DOM (#1304) * package lock changes * fix(geo): delete map legend after the printing from the DOM * test git * solve lint * solve typo and set method Access to private --- .../geo/src/lib/print/shared/print.service.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/geo/src/lib/print/shared/print.service.ts b/packages/geo/src/lib/print/shared/print.service.ts index b7d76d390c..c2220d0c05 100644 --- a/packages/geo/src/lib/print/shared/print.service.ts +++ b/packages/geo/src/lib/print/shared/print.service.ts @@ -316,7 +316,7 @@ export class PrintService { const div = window.document.createElement('div'); div.style.position = 'absolute'; div.style.top = '0'; - + div.style.zIndex = '-1'; // Add html code to convert in the new window window.document.body.appendChild(div); div.innerHTML = html; @@ -325,7 +325,7 @@ export class PrintService { const canvas = await html2canvas(div, { useCORS: true }).catch((e) => { console.log(e); }); - + this.removeHtmlElement(div); if (canvas) { let status = SubjectStatus.Done; try { @@ -345,6 +345,10 @@ export class PrintService { return status$; } + private removeHtmlElement(element: HTMLElement) { + element.parentNode.removeChild(element); + } + getTextPdfObjectSizeAndMarg(text: string, margins, font:string, fontSizeInPt: number, fontStyle:string, doc: jsPDF) : TextPdfSizeAndMargin { @@ -481,6 +485,7 @@ export class PrintService { const div = window.document.createElement('div'); div.style.position = 'absolute'; div.style.top = '0'; + div.style.zIndex = '-1'; // Add html code to convert in the new window window.document.body.appendChild(div); @@ -490,7 +495,7 @@ export class PrintService { const canvas = await html2canvas(div, { useCORS: true }).catch((e) => { console.log(e); }); - + this.removeHtmlElement(div); if (canvas) { const pourcentageReduction = 0.85; const imageSize = [pourcentageReduction * (25.4 * canvas.width) / resolution, pourcentageReduction @@ -534,6 +539,7 @@ export class PrintService { const div = window.document.createElement('div'); div.style.position = 'absolute'; div.style.top = '0'; + div.style.zIndex = '-1'; // Add html code to convert in the new window window.document.body.appendChild(div); div.innerHTML = html; @@ -541,6 +547,7 @@ export class PrintService { const canvas = await html2canvas(div, { useCORS: true }).catch((e) => { console.log(e); }); + this.removeHtmlElement(div); let marginsLegend; if (canvas) { const pourcentageReduction = 0.85; @@ -1112,6 +1119,7 @@ export class PrintService { const div = window.document.createElement('div'); div.style.position = 'absolute'; div.style.top = '0'; + div.style.zIndex = '-1'; // Add html code to convert in the new window window.document.body.appendChild(div); div.innerHTML = html; @@ -1146,7 +1154,7 @@ export class PrintService { context.drawImage(canvasLegend, legendX, legendY, legendWidth, legendHeight); context.strokeRect(legendX, legendY, legendWidth, legendHeight); - div.parentNode.removeChild(div); // remove temp div (IE style) + this.removeHtmlElement(div); return true; } }