question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error occurred when sending email of a sales order with PDF print format setting

See original GitHub issue

Description of the issue

I’m running ERPNext on my Mac Docker Desktop and having an issue where it cannot email a sales order in PDF print format. From the error log, it seems the problem is related to the package “wkhtmltopdf”. Tried to find a solution in the forum but all the answers just point the cause to the incorrect installation/version of “wkhtmltopdf”, but I believe that is not my case.

I tested “wkhtmltopdf” command in the docker container(erpnext-worker-default_1) to manually convert an html file into a pdf file for testing, and that worked without any issues. image

Context information (for bug reports)

macOS Monterey

Docker Desktop 4.2.0 (70708)

bench version erpnext 13.x.x-develop frappe 14.x.x-develop

wkhtmltopdf --version wkhtmltopdf 0.12.6 (with patched qt)

Steps to reproduce the issue

  1. setup a Gmail email account
  2. create a simple sales order
  3. email it

Stacktrace / full error message if available

stacktrach from the error log

  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 123, in send
    message = ctx.build_message(recipient.recipient)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 240, in build_message
    message = self.include_attachments(message)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 300, in include_attachments
    print_format_file = frappe.attach_print(**attachment)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1588, in attach_print
    content = get_print(doctype, name, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1554, in get_print
    return get_pdf(html, options=pdf_options, output=output)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/pdf.py", line 37, in get_pdf
    filedata = pdfkit.from_string(html, False, options=options or {})
  File "/home/frappe/frappe-bench/env/lib/python3.9/site-packages/pdfkit/api.py", line 72, in from_string
    return r.to_pdf(output_path)
  File "/home/frappe/frappe-bench/env/lib/python3.9/site-packages/pdfkit/pdfkit.py", line 156, in to_pdf
    raise IOError('wkhtmltopdf reported an error:\n' + stderr)

 Queue Name: 573d7378a8

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
revantcommented, Dec 1, 2021

mysite.localhost is simple local way to access and check erpnext on a machine. Frappe/ERPNext is ideally meant to be deployed as a web app under a https domain name. Everything is geared towards production setup.

The *.localhost sites are used to check app features locally or during local development. During development the .devcontainer directory is gitignored and it can have a complex configuration with custom docker-compose.yml based on devcontainer-example.

0reactions
a157147899commented, Dec 1, 2021

@revant thanks for your help. Finally solved the issue by adding a host entry.

Also, I am wondering that if there is a particular reason for not adding this host mapping in docker-compose.yml by default. I’ve noticed that the site name is already defined in .env file, so I guess everyone will encounter the same issue regardless of using Docker Desktop or native docker, correct?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error occurred when sending email
If I just untick the option 'Send Print as PDF' in the printing setting then it sends the email perfectly. Any help would...
Read more >
Emailing Sales Order Processing documents don't email
Company Email settings are set correctly to send docs as attachments and use PDF format. The correct messages have been setup for use...
Read more >
"The form you are about to print does not fit on the page."
When I try to email an invoice (or any form) I get the following message: "The form you are about to print does...
Read more >
NetSuite PDF file from Sales Order cannot be printed
It looks like your issue is in the Advanced HTML/PDF template associated with the form you are trying to print. ${record.duedate?string("dd ...
Read more >
Error while sending OE Invoice Report via Email
Now try to send the email, if still error occurs then you need to check the report file(.rpt) which you are using to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found