Unable to generate PDF of documents

Unable to generate PDF of any doctype. The issue started after installing ‘Print Designer’.

Blockquote
Traceback (most recent call last):
File “apps/frappe/frappe/app.py”, line 115, in application
response = frappe.api.handle(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/api/init.py”, line 49, in handle
data = endpoint(**arguments)
^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/api/v1.py”, line 36, in handle_rpc_call
return frappe.handler.handle()
^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/handler.py”, line 51, in handle
data = execute_cmd(cmd)
^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/handler.py”, line 87, in execute_cmd
return frappe.call(method, **frappe.form_dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/init.py”, line 1729, in call
return fn(*args, **newargs)
^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/utils/typing_validations.py”, line 31, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/utils/print_format.py”, line 236, in download_pdf
pdf_file = frappe.get_print(
^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/init.py”, line 2148, in get_print
return get_pdf(html, options=pdf_options, output=output) if as_pdf else html
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/utils/pdf.py”, line 80, in get_pdf
html, options = prepare_options(html, options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/utils/pdf.py”, line 160, in prepare_options
html, html_options = read_options_from_html(html)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/utils/pdf.py”, line 206, in read_options_from_html
options.update(prepare_header_footer(soup))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/utils/pdf.py”, line 315, in prepare_header_footer
html = frappe.get_attr(hook_func[-1])(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/print_designer/print_designer/pdf.py”, line 49, in pdf_header_footer_html
return pdf_header_html(
^^^^^^^^^^^^^^^^
TypeError: pdf_header_html() got an unexpected keyword argument ‘path’

The error you’re seeing:

TypeError: pdf_header_html() got an unexpected keyword argument ‘path’

is happening because Print Designer overrides the default pdf_header_footer_html function in ERPNext, and its version of the function (pdf_header_html) doesn’t accept the path argument — but Frappe now expects it in its latest versions.


:white_check_mark: Root Cause

The print_designer app has a pdf.py file that defines a pdf_header_html() function, which is being called via hook from Frappe. But Frappe’s latest version started passing a path keyword argument that this function is not expecting.


:hammer_and_wrench: Fix Options

Option 1: Patch pdf_header_html() in Print Designer

Edit the file:
apps/print_designer/print_designer/pdf.py

Update the function definition to include **kwargs:

def pdf_header_html(doc, meta, is_header=True, **kwargs):
    # your existing code here

This way, even if Frappe passes additional unexpected arguments like path, the function won’t crash.

:repeat: After editing the file, run:

bench restart

Option 2: Temporarily Disable the Hook (Quick Bypass)

You can also comment out the PDF header/footer hook in the hooks.py of Print Designer to use Frappe’s default behavior.

In apps/print_designer/print_designer/hooks.py, look for something like:

override_whitelisted_methods = {
    "frappe.utils.print_format.get_pdf": "print_designer.pdf.get_pdf"
}

Or:

doc_events = {
    "*": {
        "pdf_header_footer_html": "print_designer.pdf.pdf_header_html"
    }
}

Comment or remove the override related to pdf_header_html and restart:

bench restart

:white_check_mark: Best Practice (Long Term)

  • Report the issue on the Print Designer GitHub repo if it’s not maintained.
  • If you’re using ERPNext v14 or v15, ensure Print Designer is compatible with it.
  • Fork it or wait for an updated release that supports the new PDF header/footer handling.

1 Like