diff --git a/src/assets/js/usePrint.js b/src/assets/js/usePrint.js index 9767d45..e402fe0 100644 --- a/src/assets/js/usePrint.js +++ b/src/assets/js/usePrint.js @@ -1,11 +1,10 @@ import { ref } from "vue"; -export default function usePrint(THEAD_HEIGHT) { +export default function usePrint() { const buttonRef = ref(null); const A4_HEIGHT_MM = 297; const A4_HEIGHT_MM_TO_PX_PROPORTION = 3.78; - let A4_HEIGHT_PX = - A4_HEIGHT_MM * A4_HEIGHT_MM_TO_PX_PROPORTION - THEAD_HEIGHT; + let A4_HEIGHT_PX = A4_HEIGHT_MM * A4_HEIGHT_MM_TO_PX_PROPORTION; let elements = []; const printObj = { id: "printContent", @@ -16,9 +15,9 @@ export default function usePrint(THEAD_HEIGHT) { const fnPrint = () => { document.querySelector("#printContent").style.overflow = "visible"; elements = document.querySelectorAll("#printContent > table > tr"); - if (!document.querySelector("#printContent > table thead")) { - A4_HEIGHT_PX = A4_HEIGHT_PX + THEAD_HEIGHT; - } + const thead = document.querySelector("#printContent > table thead"); + if (thead) A4_HEIGHT_PX = A4_HEIGHT_PX - thead.offsetHeight; + else A4_HEIGHT_PX = A4_HEIGHT_PX + thead.offsetHeight; fnIsPaging(); buttonRef.value.$el.click(); }; diff --git a/src/components/pdf/index.vue b/src/components/pdf/index.vue index 7dc3b15..73ecff2 100644 --- a/src/components/pdf/index.vue +++ b/src/components/pdf/index.vue @@ -1,5 +1,9 @@