From c59c25bff510166011471b136d12c4217f844eb9 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Fri, 7 Apr 2023 07:01:49 +0530 Subject: Changed the way pdf is downloaded for plot & khatian details. --- src/shared/download-pdf.ts | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'src/shared/download-pdf.ts') diff --git a/src/shared/download-pdf.ts b/src/shared/download-pdf.ts index e741942..bd8f815 100644 --- a/src/shared/download-pdf.ts +++ b/src/shared/download-pdf.ts @@ -1,23 +1,17 @@ -const autoPrintCode = ` - -`; - export const downloadPDF = (content: string) => { const tab = window.open("about:blank", "_blank"); if (tab) { - tab.document.write(content + autoPrintCode); + tab.document.write(content); tab.document.close(); + tab.focus(); + Promise.all(Array.from(tab.document.images) + .filter(img => !img.complete) + .map(img => new Promise(resolve => { + img.onload = img.onerror = resolve; + }))).then(() => { + tab.print(); + tab.close(); + }); } }; -- cgit v1.2.3