From a4746483ab34de99f7c96f1fce3ec95bc1c6be90 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 19 Oct 2021 19:20:08 +0530 Subject: [PATCH] fix: print style - bordered table - pdf column rendering fix - document-header class --- .../templates/print_format/macros/Table.html | 2 +- .../templates/print_format/print_format.css | 23 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/frappe/templates/print_format/macros/Table.html b/frappe/templates/print_format/macros/Table.html index 7febc899e4..27c0be961c 100644 --- a/frappe/templates/print_format/macros/Table.html +++ b/frappe/templates/print_format/macros/Table.html @@ -3,7 +3,7 @@
{{ df.label }}
- +
{% set columns = df.table_columns %} diff --git a/frappe/templates/print_format/print_format.css b/frappe/templates/print_format/print_format.css index 987e6f3093..cb87af301e 100644 --- a/frappe/templates/print_format/print_format.css +++ b/frappe/templates/print_format/print_format.css @@ -12,8 +12,8 @@ margin-bottom: {{ print_format.margin_bottom | int }}mm; margin-left: {{ print_format.margin_left | int }}mm; margin-right: {{ print_format.margin_right | int }}mm; - padding-top: {{ header_height }}px; - padding-bottom: {{ footer_height }}px; + padding-top: {{ (header_height or 0) + 8 }}px; + padding-bottom: {{ (footer_height or 0) + 8 }}px; /* page number */ {% set page_number_position = print_format.page_number.lower().replace(' ', '_') %} @@ -31,6 +31,15 @@ body { max-width: {{ body_width | int }}mm !important; } +/* CSS rules to fix bootstrap column rendering in PDF + https://github.com/Kozea/WeasyPrint/issues/697#issuecomment-542338732 +*/ +@media print { + .col, *[class^="col-"] { + max-width: none !important; + } +} + @media screen { html { background-color: var(--gray-200); @@ -74,12 +83,12 @@ body { page-break-inside: avoid; } -.table-row td, .table-row th { +.page-break { + page-break-after: always; +} + +.document-header { border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: var(--gray-300); } - -.page-break { - page-break-after: always; -}