Can we print header on all pages with page number in print format

I want to print header on all pages in my new custom print format with page numbers.
As my table contain many rows so i want to dynamically break page & print header with table contents.
So is it possible ?

1 Like


Yes you can print footer and page number with letter head.
Please refer this code.

1 Like

Hello @kolate_sambhaji
I used the above code still not able to get header & footer on all pages.
Is there any css for header & footer?

Can you share your code?

Sorry @kolate_sambhaji, i was checking in normal print, this feature is only visible in pdf was known to me later.
Thank You so much for the help.

1 Like

Hiee @kolate_sambhaji
Actually i needed to make header more bold, what should i do ?

In header-html, write your html code to bold text.

@kolate_sambhaji where is the header html file located ?

please check above code, you need to write head code in div id header-html, or you can add header from Letter Head doctype.

When I add the following into my Print Format:

<div id="header-html" class="hidden-pdf">
    {{ add_header(0,1,doc,letter_head, no_letterhead) }}

I get this error: 'add_header' is undefined

Has this been changed?

Full traceback:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 62, in application
    response = frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 22, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 53, in execute_cmd
    return, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 939, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/www/", line 188, in get_html_and_style
    no_letterhead=no_letterhead, trigger_print=trigger_print),
  File "/home/frappe/frappe-bench/apps/frappe/frappe/www/", line 159, in get_html
    html = template.render(args, filters={"len": len})
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<template>", line 2, in top-level template code
UndefinedError: 'add_header' is undefined

Found it! It should be {{ letter_head }} in there:

<div id="header-html" class="hidden-pdf">
    {{ letter_head }}

what have you put in your letter head file?