Skip to content

Commit

Permalink
feat: ⚡️ more stable view in the html preview and pdf
Browse files Browse the repository at this point in the history
- the header can span over the whole page width.
- the with of elements is given hard coded instead of relaying on margins.
- for the footer the page number cant be processed py the html view therefore don't show it.
- the footer is not positioned right in the html view. a lot off margin parameters are handled different in html view and pdf. for the footer none could be found to solve it for both. therefore the html view got an fixed positoned footer.
  • Loading branch information
Sven Förster committed Oct 16, 2024
1 parent bb70ff0 commit 6846ede
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 88 deletions.
17 changes: 5 additions & 12 deletions print_format/delivery_note.jinja
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
<style>
.print-format {
margin-left: 0mm;
margin-right: 0mm;
margin-top: 10mm;
margin-bottom: 45mm;
font-size: 10pt;
}
</style>

{% set company = frappe.get_doc("Company", doc.company) %}
{% set cmp_addr = frappe.get_doc("Address", doc.company_address) if doc.company_address else None %}
{% set ship_addr = frappe.get_doc("Address", doc.shipping_address_name) if doc.shipping_address_name else None %}
Expand Down Expand Up @@ -134,10 +124,13 @@
<!-- FOOTER -->
<div id="footer-html" class="visible-pdf">
<div class="letter-head-footer">
<p id="pagenum">
<p id="pagenum" class="visible-pdf">
{{ _("Page {0} of {1}").format('<span class="page"></span>', '<span class="topage"></span>') }}
</p>
<div class="print-format-footer">
<div class="print-format-footer visible-pdf">
{{ footer }}
</div>
<div class="print-format-footer-html hidden-pdf">
{{ footer }}
</div>
</div>
Expand Down
17 changes: 5 additions & 12 deletions print_format/dunning.jinja
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
<style>
.print-format {
margin-left: 0mm;
margin-right: 0mm;
margin-top: 10mm;
margin-bottom: 45mm;
font-size: 10pt;
}
</style>

{% set sales_invoice = frappe.get_doc("Sales Invoice", doc.sales_invoice) %}
{% set company = frappe.get_doc("Company", doc.company) %}
{% set cmp_addr = frappe.get_doc("Address", sales_invoice.company_address) if sales_invoice.company_address else None %}
Expand Down Expand Up @@ -168,10 +158,13 @@
<!-- FOOTER -->
<div id="footer-html" class="visible-pdf">
<div class="letter-head-footer">
<p id="pagenum">
<p id="pagenum" class="visible-pdf">
{{ _("Page {0} of {1}").format('<span class="page"></span>', '<span class="topage"></span>') }}
</p>
<div class="print-format-footer">
<div class="print-format-footer visible-pdf">
{{ footer }}
</div>
<div class="print-format-footer-html hidden-pdf">
{{ footer }}
</div>
</div>
Expand Down
17 changes: 5 additions & 12 deletions print_format/purchase_order.jinja
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
<style>
.print-format {
margin-left: 0mm;
margin-right: 0mm;
margin-top: 10mm;
margin-bottom: 45mm;
font-size: 10pt;
}
</style>

{% set company = frappe.get_doc("Company", doc.company) %}
{% set cmp_addr = frappe.get_doc("Address", doc.billing_address) if doc.billing_address else None %}
{% set pay_addr = frappe.get_doc("Address", doc.supplier_address) if doc.supplier_address else None %}
Expand Down Expand Up @@ -202,10 +192,13 @@
<!-- FOOTER -->
<div id="footer-html" class="visible-pdf">
<div class="letter-head-footer">
<p id="pagenum">
<p id="pagenum" class="visible-pdf">
{{ _("Page {0} of {1}").format('<span class="page"></span>', '<span class="topage"></span>') }}
</p>
<div class="print-format-footer">
<div class="print-format-footer visible-pdf">
{{ footer }}
</div>
<div class="print-format-footer-html hidden-pdf">
{{ footer }}
</div>
</div>
Expand Down
17 changes: 5 additions & 12 deletions print_format/quotation.jinja
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
<style>
.print-format {
margin-left: 0mm;
margin-right: 0mm;
margin-top: 10mm;
margin-bottom: 45mm;
font-size: 10pt;
}
</style>

{% set company = frappe.get_doc("Company", doc.company) %}
{% set cmp_addr = frappe.get_doc("Address", doc.company_address) if doc.company_address else None %}
{% set pay_addr = frappe.get_doc("Address", doc.customer_address) if doc.customer_address else None %}
Expand Down Expand Up @@ -218,10 +208,13 @@
<!-- FOOTER -->
<div id="footer-html" class="visible-pdf">
<div class="letter-head-footer">
<p id="pagenum">
<p id="pagenum" class="visible-pdf">
{{ _("Page {0} of {1}").format('<span class="page"></span>', '<span class="topage"></span>') }}
</p>
<div class="print-format-footer">
<div class="print-format-footer visible-pdf">
{{ footer }}
</div>
<div class="print-format-footer-html hidden-pdf">
{{ footer }}
</div>
</div>
Expand Down
17 changes: 5 additions & 12 deletions print_format/request_for_quotation.jinja
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
<style>
.print-format {
margin-left: 0mm;
margin-right: 0mm;
margin-top: 10mm;
margin-bottom: 45mm;
font-size: 10pt;
}
</style>

{% set bill_addr = frappe.get_doc("Address", doc.company_address) if doc.company_address else None %}
{% set company = frappe.get_doc("Company", doc.company) %}

Expand Down Expand Up @@ -133,10 +123,13 @@
<!-- FOOTER -->
<div id="footer-html" class="visible-pdf">
<div class="letter-head-footer">
<p id="pagenum">
<p id="pagenum" class="visible-pdf">
{{ _("Page {0} of {1}").format('<span class="page"></span>', '<span class="topage"></span>') }}
</p>
<div class="print-format-footer">
<div class="print-format-footer visible-pdf">
{{ footer }}
</div>
<div class="print-format-footer-html hidden-pdf">
{{ footer }}
</div>
</div>
Expand Down
17 changes: 5 additions & 12 deletions print_format/sales_invoice.jinja
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
<style>
.print-format {
margin-left: 0mm;
margin-right: 0mm;
margin-top: 10mm;
margin-bottom: 45mm;
font-size: 10pt;
}
</style>

{% set company = frappe.get_doc("Company", doc.company) %}
{% set cmp_addr = frappe.get_doc("Address", doc.company_address) if doc.company_address else None %}
{% set pay_addr = frappe.get_doc("Address", doc.customer_address) %}
Expand Down Expand Up @@ -354,10 +344,13 @@
<!-- FOOTER -->
<div id="footer-html" class="visible-pdf">
<div class="letter-head-footer">
<p id="pagenum">
<p id="pagenum" class="visible-pdf">
{{ _("Page {0} of {1}").format('<span class="page"></span>', '<span class="topage"></span>') }}
</p>
<div class="print-format-footer">
<div class="print-format-footer visible-pdf">
{{ footer }}
</div>
<div class="print-format-footer-html hidden-pdf">
{{ footer }}
</div>
</div>
Expand Down
17 changes: 5 additions & 12 deletions print_format/sales_order.jinja
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
<style>
.print-format {
margin-left: 0mm;
margin-right: 0mm;
margin-top: 10mm;
margin-bottom: 45mm;
font-size: 10pt;
}
</style>

{% set company = frappe.get_doc("Company", doc.company) %}
{% set cmp_addr = frappe.get_doc("Address", doc.company_address) if doc.company_address else None %}
{% set pay_addr = frappe.get_doc("Address", doc.customer_address) %}
Expand Down Expand Up @@ -241,10 +231,13 @@
<!-- FOOTER -->
<div id="footer-html" class="visible-pdf">
<div class="letter-head-footer">
<p id="pagenum">
<p id="pagenum" class="visible-pdf">
{{ _("Page {0} of {1}").format('<span class="page"></span>', '<span class="topage"></span>') }}
</p>
<div class="print-format-footer">
<div class="print-format-footer visible-pdf">
{{ footer }}
</div>
<div class="print-format-footer-html hidden-pdf">
{{ footer }}
</div>
</div>
Expand Down
24 changes: 20 additions & 4 deletions print_style/print_style.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
.print-format {
padding: 0;
position: relative;
margin-left: 0mm;
margin-right: 0mm;
margin-top: 10mm;
margin-bottom: 45mm;
font-size: 10pt;

#header {
width: 100%;
/* ( 45 mm - 10 mm margin ) */
height: 35mm;
/* Overwrite empty header inserted by frappe */
margin-top: -10mm;
overflow: hidden;
position: relative;
margin-left: 25mm;
Expand Down Expand Up @@ -84,6 +86,7 @@
margin-top: 8.46mm;
margin-left: 25mm;
margin-right: 20mm;
width: 165mm;
}

.text-right {
Expand Down Expand Up @@ -135,14 +138,27 @@

.print-format-footer {
margin-left: 25mm;
padding-right: 20mm;
width: 165mm;
margin-right: 20mm;
}

.print-format-footer-html {
margin-left: 25mm;
width: 165mm;
height: 20mm;
margin-right: 20mm;
margin-top: -45mm;
bottom: 10mm;
position: absolute;
}

#pagenum {
text-align: right;
margin-right: 20mm;
margin-top: 4.23mm;
margin-bottom: 4.23mm;
margin-left: 25mm;
width: 165mm;
}

body, html {
Expand Down

0 comments on commit 6846ede

Please sign in to comment.