From de13ddbf5cb41c5447f02dd95ba2f413f47b9f90 Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Tue, 16 Sep 2025 20:37:54 +0200 Subject: [PATCH] (pl)(spis) make census more print-friendly --- app/assets/print.scss | 16 ++++++++++++++-- app/layouts/default.vue | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/assets/print.scss b/app/assets/print.scss index 4f53c24e6..d5d840dbc 100644 --- a/app/assets/print.scss +++ b/app/assets/print.scss @@ -5,8 +5,8 @@ display: none; } body { - background: none; - background-color: $white; + background: none !important; + color: $black !important; } hr { display: block; @@ -16,4 +16,16 @@ @page { margin: 1cm; } + + details { + break-inside: avoid; + margin-bottom: 1em; + p { + margin: 1em; + } + } + + th, td { + color: $black !important; + } } diff --git a/app/layouts/default.vue b/app/layouts/default.vue index 3c6057b19..5cb00f001 100644 --- a/app/layouts/default.vue +++ b/app/layouts/default.vue @@ -92,6 +92,20 @@ onMounted(executeUnlessPrerendering(() => { window.location.reload(); } }; + + // making census reports print-friendly + window.addEventListener("beforeprint", () => { + document.querySelectorAll("iframe[loading=lazy]").forEach(iframe => { + iframe.removeAttribute("loading"); + iframe.setAttribute("src", iframe.getAttribute("src")!); + }); + document.querySelectorAll("iframe.graph").forEach(iframe => { + const graph = iframe as HTMLIFrameElement; + graph.style.width = "718px"; // A4 width - 1cm margins at 96dpi + graph.style.height = "400px"; + }); + document.querySelectorAll("details").forEach(d => d.setAttribute("open", "")); + }); })); const dialogue = useDialogue();