How can I limit item under table to 4 row and page break to second page with existing page header? Include page number
Besides that, I facing the issue for the doc.terms fields which having some format issue and cause entire custom print format run out.
My custom print template
{%- macro add_header(page_num, max_pages, doc, letter_head, no_letterhead) -%}
{% if letter_head and not no_letterhead %}
{{ letter_head }}
{% endif %}
{%- if doc.meta.is_submittable and doc.docstatus==0-%}
{{ _(“DRAFT”) }}
{%- endif -%}
{%- if doc.meta.is_submittable and doc.docstatus==2-%}
{{ _(“CANCELLED”) }}
{%- endif -%}
{% if max_pages > 1 %}
{{ _(“Page #{0} of {1}”).format(page_num, max_pages) }}
You can combine your items loop with a counter which will insert a page-break after every 4 items. Header and footer should be normally defined, then they will repeat on each page, e.g. like this
<!-- HEAD -->
<div id="header-html" class="hidden-pdf">
{% set letter_head = frappe.get_doc("Letter Head", "Standard") %}
{% if letter_head %}
{{ letter_head.content }}
{% else %}
<p>Letter head Standard not found. Please define the letter head under print settings.</p>
{% endif %}
</div>
and
<!-- page footer -->
<div id="footer-html" class="visible-pdf">
{% if letter_head %}
{{ letter_head.footer }}
{% else %}
<p>No letter head found. Please define a letter head under print settings and mark it as default</p>
{% endif %}
<p style="font-size: 6pt !important; text-align: right">
{{ _("Page") }} <span class="page"></span> {{ _("of") }} <span class="topage"></span>
</p>
</div>
As for the format issues of the doc.terms, I am not quite sure what they are. Maybe a screenshot might help…
Thanks Lasalesi for the reply.
As my colleagues have left the company and i’m not ideas how this custom print template been build. possible to guide me how to input the page break under the code?
here the entire template quote:
{%- macro add_header(page_num, max_pages, doc, letter_head, no_letterhead) -%}
{% if letter_head and not no_letterhead %}
{{ letter_head }}
{% endif %}
{%- if doc.meta.is_submittable and doc.docstatus==0-%}
{{ _(“DRAFT”) }}
{%- endif -%}
{%- if doc.meta.is_submittable and doc.docstatus==2-%}
{{ _(“CANCELLED”) }}
{%- endif -%}
{% if max_pages > 1 %}
{{ _(“Page #{0} of {1}”).format(page_num, max_pages) }}
how can i do that ???
You can combine your items loop with a counter which will insert a page-break after every 4 items. Header and footer should be normally defined, then they will repeat on each page