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?

Edit:
Seems that this ā€œissueā€ is working in Odooā€¦maybe we should take a look at ā€œtheirā€ PDF engine?

Cheers,
Dan

Hi,

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>


                                            </tr>
                                            {% endfor %}

@daniel can you share screenshots?

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

@anand
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:

edit:
can we delete the ā€œDraftā€ as well?

best,
Dan

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:

@anand,

Sorry for bothering you again. But I tried not a lotā€¦it does not recognize ā€œdoc.ā€ do I have to call a macro before?

Best,
Dan

@daniel

There is no variable called ā€˜dataā€™, use doc only

@anand

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ā€¦

Edit:
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

best,
Dan

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!
Daniel

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?

Best,
Daniel

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

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

IS AWESOME.

1 Like

so this is due in a few days?
Daniel

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