PDF Print & Custom Naming Series problems

Hai,

  1. We are facing 404 error with our custom naming series . When the email link ‘View this in your browser’ is opened , we are getting 'The resource you are looking for is not available ’ . But there is no problem with default naming series like SO or SINV.
  2. Also , Pdf output is not rendering many html elements correctly, colors and elements are missing in PDF. This problem is being faced by many users.
    Can we solve this?

What is your naming series? Please share it and also share your error.

This is for Sales Order , and

Naming Series is BE/.abbreviation./17-18/.###
where abbreviation is a custom field in doc, sales order is created successfully with series BE/AGWS/17-18/002 but the same can not be viewed from the email link. Error logged in console is “Failed to load resource: the server responded with a status of 404 (NOT FOUND)”

Sorry for bothering , its just the problem with “/” in naming series , replacing “/” with “-” solved the problem.
But PDF rendering problem is a major issue.

Okay. Share your PDF screenshot.

Actual format

Pdf Output

Note: All the custom elements are styled with inline CSS

Which Pdf library is used in Frappe/ErpNext? Because pdf is working even when I uninstalled wkhtmltopdf.

Hi @raghu9,

ERPNext/Frappe is using wkhtmltopdf as pdf generator. If you uninstall it and it can still generate pdfs, something strange happens. Could it be a mismatch in VM/server? What is the answer on which wkhtmltopdf? What is wkhtmltoppdf -V (should be wkhtmltopdf 0.12.3 (with patched qt)…

Yes, this is exactly what I am getting, that means wkhtmltopdf is working perfectly, then it must be the problem with rendering from html to pdf. I tried custom CSS in print format, but it doesn’t change anything.

Can you extract your html code any manually process it? Add a temporary

frappe.throw(html) 

after line 13 in apps/frappe/utils/pdf.py, (if production, run bench migrate && bench restart) then create a pdf and paste the contents from the inner html block from the exception to a html file, copy it to the server and run

$ wkhtmltopdf file.html file.pdf

Are there any error messages?

added the line, bench migration is done, but couldn’t understand this line, dont know how to do this.

Yes done, error shown is
Loading pages (1/6)
Warning: SSL error ignored
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
Exit with code 1 due to network error: ProtocolUnknownError

After inserting the frappe.throw(html), when you try to create a pdf, it will show an error instead which contains the html code of the pdf to be generated:

Right click on this and select “View Source Code”:

Then, look for the inner html, which is the actual html that would go to wkhtmltopdf, it is where <!DOCTYPE HTML><html>...</html> are found:

Extract this to a new file, copy to the server and process with wkhtmltopdf. This should give you a much more detailed error trace.

This Solved my problem, hope it helps others too.