Email-SalesInvoice-PDF parts missing

Hi there,

i have an issue with the print formats.
I created a new one. Customizing it by using the grad’Ndrop editor.
= > fine so far. Normal Print work.

Now i try to send this invoice as email attachment (the default web functionality) select my custom format.

The arriving email contains the invoice as PDF.
But here is the point: In this PDF the invoice has no header or footer.
It shows just the middle part with the containing data.
(frappe/erpnext v13.8.x) updated today…
What I am missing here?..
Im doing it wrong?
How is it meant to be used?

Is there may an example to put a file based custom print format on an custom_app, so i can push it into a git repository?

ty for helping out…

bg Desian

Firstly you need to test if the invoice actually gets converted to pdf properly with header and footer. Dont go on what you see on print preview. Press the pdf button to convert it. Mostly probably it is same as the email attachment. Check your code for header and footer error.

You maybe printing directly using browser without converting to pdf. Which is why it looks fine.

This is correct.
The generated PDF (the PDF-Button on the invoice) also do not show the header.
Why this is different from the print view? This is confusing to me.
How i can make it happen to see the regular header/footer every site on the PDF?
What is the intended behavior?

bg Desien

Share your print format. You need to set like this for header

{%- from "templates/print_formats/standard_macros.html" import add_header -%}
{% set delivery = [] %}
<div {% if print_settings.repeat_header_footer %} id="header-html" class="hidden-pdf" {% endif %}>
        {% if letter_head %}
        <div class="letter-head" style="margin-top: 15px!important;">{{ letter_head }}</div>

Add this in footer

<div class="row">
  <div id="footer-html" class="visible-pdf">
    {% if not no_letterhead and 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>

And in CSS do this

@media print {
  footer {page-break-after: always;}
}
1 Like

Thank you for your effort.
The print format is made only by clicking in the frontend on my local dev-server.
So i don’t know how to share it.
Inserting this code into this HTML-Form was not repeating the header on every page of the pdf.

So i was trying to figure out to use your hint by creating this files:

custumization/print_format/my_format.json = > used
custumization/print_format/my_format.html
(used /erpnext/account/print_format/sales_auditing_voucher/* as an example)

after “bench migrate” i see my custom format in the list of print formats.

If im selecting the format in preview, i get

  • “No preview available.”
    And when i try to see the PDF
  • {{ body }}

I was not able to find documentation about the format of the json or how i can exactly bring this custom print format to live.

How i convince the print-format to use my html file?
Where i can find documentation, that also explain things in the source code rather than only by using the frontend?
Maybe: witch project i can checkout for an example?

bg Desian

Aah. I think you are using the internal drag and drop print format builder. Share images then of the setup.

Check your print settings to be sure Print with letterhead etc are checked.

A year later!

Cannot get a PDF file with a header.

Installed Apps

ERPNext: v13.35.1 (version-13)

Frappe Framework: v13.35.0 (version-13)

© Frappe Technologies Pvt. Ltd and contributors 

I’ve been playing with different settings for an hour already, including turning on and off “Print with Letterhead” as you suggested.

I defined a default letterhead in Company Settings.

Trying with a Sales Order:

  • I specified Letterhead and Print Heading in the Print Settings section of the Sales Order.
  • the print preview shows the changes I made to the heading

If I send it to print, and select print to PDF, then I get what I need.

However, the PDF produced from the PDF button …

Screenshot_2022-07-31_12-51-13

… refuses to include a heading of any kind.

Is this expected?

Read through this thread. I had same problem a few months ago and updated my wkhtmltopdf version to fix it.

Hope this helps…

BKM

That fixed it!

Really weird to see the number of questions about failing PDFs going all the way back to 2014.

I appreciate this. Thanks for taking the time.

Wkhtmtopdf is a major pain, and because it needs to be installed at the system level there’s very little Frappe can do to control it. There are hundreds of threads, like you say, and the overwhelming majority of the time the issue is either binary versions or addressing/permissions.

Thankfully, v14 dumps wkhtmltopdf for weasyprint.

1 Like

Wheezy Print

:rofl:

Is that like … PDF with Long COVID?

(Nice clarification. Thank you :wink:)

1 Like