ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Custom Print Format EMPTY PDF file

print_format

#1

I have written a custom print format for a docType, print is perfect as I wanted. Now when I click on PDF to generate pdf file it shows empty pages.

Its like PDF file with a empty page. Nothing is writtten on it.


#2

Hi @avaiskhatri,

this is most probably originating from an issue with your code and wkhtmltopdf. You can debug it for example like this: PDF no logo shown

Hope this helps.


#3

Hi @lasalesi,

Default format are working fine for PDF, the blank page shows when used custom print format.


#4

Hi @avaiskhatri ,

I understand that the standard works, but not the custom… this is why I guess there is an issue with your code (is it a print format based on “custom print format”, using html code). Have you tried the above debug? Or analysed your html for compatibility?


#5

Yes. I have added following to frappe/frappe/utils/pdf.py after line 12

frappe.log_error(html)

bench restart

Still frappe.log doesn’t show any thing.


#6

Hi @lasalesi,

upon running this command test.pdf was generated with out any error, though the layout was totally destroyed that may due to styling.

$ wkhtmltopdf test.html test.pdf

But when click on PDF button from print area, PDF with empty pages is generated.


#7

Have you checked that you have the latest version of wkhtmltopdf? (0.12.5.x I think)


#8

Hi, I debugged my format by removing all the html and css code. Later I start by adding one 1 block of code to print format and tested with PDF until all my html code was pasted.

I found that there was issue with my css code. In the end css was found to be the culprit.

Thanks @lasalesi for the continous support.

:slight_smile:


#9

Thanks for your feedback, glad you could resolve it.