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.
---
.../view-khatian/download-document-content.ts | 5 +----
src/shared/download-pdf.ts | 26 +++++++++-------------
2 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/src/scripts/functionality/view-khatian/download-document-content.ts b/src/scripts/functionality/view-khatian/download-document-content.ts
index 594db5e..249e2b1 100644
--- a/src/scripts/functionality/view-khatian/download-document-content.ts
+++ b/src/scripts/functionality/view-khatian/download-document-content.ts
@@ -17,11 +17,8 @@ export default (isPlotInformation: boolean, details: string, { district, block,
#content {
width: 100%;
- min-height: calc(100vw * 1.4);
margin: 0;
padding: 0;
- display: flex;
- flex-direction: column;
}
.banner {
@@ -189,7 +186,7 @@ export default (isPlotInformation: boolean, details: string, { district, block,
.footer {
width: 100%;
- margin-top: auto;
+ margin-top: 1rem;
}
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