Repeat header & footer in custom print format on each page of pdf - ashish-greycube/help GitHub Wiki

Follow following steps:

  1. Run following command first to check wkhtmltopdf version wkhtmltopdf -V It should be wkhtmltopdf 0.12.5 (with patched qt)
  2. Open Print Settings
Enable Repeat Header and Footer in PDF
  1. In print format:

For header write following code:

{%- from "templates/print_formats/standard_macros.html" import add_header, render_field, print_value, fieldmeta, get_width, get_align_class with context -%}

{% if print_settings.repeat_header_footer %}
    <div id="header-html">
        {% if letter_head and not no_letterhead %}
            <div class="letter-head">{{ letter_head }}</div>
        {% else%}
             <div>
               <table>
                <tr></tr>
               </table>
               </div>
        {% endif %}
   </div>
{% endif %}

For footer

{% if print_settings.repeat_header_footer %}
<div id="footer-html">
    {% if footer %}
    <div class="letter-head-footer"> {{ footer }} </div>
    {% endif %}
    <p class="text-center small page-number visible-pdf">
        {{ _("Page {0} of {1}").format('<span class="page"></span>', '<span class="topage"></span>') }} </p>
</div>
{% endif %}
⚠️ **GitHub.com Fallback** ⚠️