PDF output looks bad

Hi @all,

I am looking for a solution on how to make the PDF printout look exactly the same as on the preview. Seems that it is not working sind 2014 :wink: guess we have discussed this topic already earlier.

Since I am now actively working on my ERPNext v6 copy I am still wondering why the PDF does not look as expected :frowning:

Any clues what’s wrong?

Btw the Problem:
Tables created in the Format-Builder are not going to be printed correctly, they are stated all below each other.

Only the “Title” and the products-table is shown (nearly) as expected.

Any others got that problem?

Seems that this “issue” is working in Odoo…maybe we should take a look at “their” PDF engine?



since I stumbled upon a few hints on external sources regarding wk html to pdf I am about to build a complete custom form using my HTML and CSS Knowledge. That works so far very well with “static” data.

Since you know I’ve moved from V4 I still have the following code made for my last printout…but it seems to be not valid any more.

{% for doc in data %}

                                                    <td>{{ doc.idx }}</td>

                                                            <td>{{ doc.item_code }}</td>
                                                            <td>{{ doc.item_name }}</td>
                                                            <br>{{ doc.description }}</td>
                                                            <td class="text-right">{{ doc.qty }}</td>
                                                             <td class="text-right">{{ doc.get_formatted("base_price_list_rate") }}{%- if doc.discount_percentage -%}<br>- {{ doc.discount_percentage }} %{%- endif -%}</td>
                                                            <td class="text-right">{{ doc.get_formatted("base_amount") }}</td>

                                            {% endfor %}

@daniel can you share screenshots?

also can you reproduce this at https://demo.erpnext.com?

Thanks for your message.
I cannot reproduce @ demo because I can’t create a new print-template.

Regarding screenshot:

The first one is - as you assume - the “original printout”.
The second one is my company’s CI lookalike…ps: the table with products is just dummy-data as it is not working :confused:

can we delete the “Draft” as well?


no one?

In the Print Format record, you need to set:

  1. Standard = No
  2. Custom Format = checked
  3. Print Format Type = Standard
  4. Write your code in HTML

Now you can write any Jinja that you want. See the help at the bottom of the Print Format doc.

This is still not working :confused:


Sorry for bothering you again. But I tried not a lot…it does not recognize “doc.” do I have to call a macro before?



There is no variable called ‘data’, use doc only


Wow, that was a really fast information. Yep, the output is not “ok”. One more question, how is the page-break defined in standard output? I can’t seen to find it in standard.html…

I’d like to help you and share my code with others…but where is the printout of the PDF itself defined?
I want to add a header to the printout and I want to check if advanced WKHTMLTOPDF options are possible. This may help further development of ERPNext? Thanks already in advance @anand


Give a div class=“page-break”

thank you @anand

But basically what I mean in detail is:
Where is the function itself that generates the PDF. Because since WKHTMLTOPDF offers a variety of options like header and footer for printout, I’d like to test it. But I can’t seem to find the corresponding file to change it.

Thanks in advance!

Search for pdf.py

Hi @anand,

thanks for that information.
You guess right: another question arises now…sorry for that :frowning:

I am now running a multi-site-setup with 3x ERPNext. Problem…when I change e.g. the --background in pdf.py options, that changes my output in all 3 sites…is there a change to differentiate?


1 Like

Since the code is common, it will affect all sites.

You should either put the modified code in another frappe app and call it via hook, or use multiple benches. But right now multiple benches will be tricky to setup.

1 Like

I have to admit that the hooks are not my first choice…a multi-bench-setup would be f* great :wink: but right now since this is kind of tricky I won’t recommend that either.

I guess the better choice here is to choose more servers ?

What just came to my mind…how about doing it with like an if function. Is there a possibility for the pdf.py to determine which site is calling the python file?

You are in luck. We are going to release a multi-bench fix next week: [Major] Multi-bench setup by shreyasp · Pull Request #187 · frappe/bench · GitHub

Where can I just put you on top of my fav devs :wink: this


1 Like

so this is due in a few days?

Yes still a few issues to iron out before it is ready for production use