Error on sending Email and generating PDF - HELP please!

I’m getting an error when trying to email a Sales Order with PDF Attachment of a custom Print Format. The main error says:

Error generating PDF, attachment sent as HTML
There were errors while sending email. Please try again.

When I look at the Javascript console log I see this: GET 404 (OK)
2015-05-04 16:58:26.316 frappe.min.js:310 Traceback (innermost last):
  File "/home/frappe/press/benches/1504281352/apps/frappe/frappe/core/doctype/communication/", line 156, in attach_print
    mail.add_pdf_attachment(name.replace(' ','').replace('/','-') + '.pdf', print_html)
  File "/home/frappe/press/benches/1504281352/apps/frappe/frappe/utils/email_lib/", line 157, in add_pdf_attachment
    self.add_attachment(name, get_pdf(html, options), 'application/octet-stream')
  File "/home/frappe/press/benches/1504281352/apps/frappe/frappe/utils/", line 29, in get_pdf
    pdfkit.from_string(html, fname, options=options or {})
  File "/home/frappe/press/benches/1504281352/env/lib/python2.7/site-packages/pdfkit/", line 68, in from_string
    return r.to_pdf(output_path)
  File "/home/frappe/press/benches/1504281352/env/lib/python2.7/site-packages/pdfkit/", line 116, in to_pdf
    raise IOError('wkhtmltopdf reported an error:\n' + stderr.decode('utf-8'))
 IOError: wkhtmltopdf reported an error:
Loading pages (1/6)
[>                                                           ] 0%
[======>                                                     ] 10%
[=============================>                              ] 49%
[=====================================>                      ] 62%
[===========================================>                ] 72%
[============================================================] 100%
Counting pages (2/6)                                               
[============================================================] Object 1 of 1
Resolving links (4/6)                                                       
[============================================================] Object 1 of 1
Loading headers and footers (5/6)                                           
Printing pages (6/6)
[>                                                           ] Preparing
[===================>                                        ] Page 1 of 3
[=======================================>                    ] Page 2 of 3
[============================================================] Page 3 of 3
Exit with code 1 due to network error: UnknownNetworkError

I really need to get this working so we can send proofs to customers automatically. At the moment it is not working at all :frowning:

Is this dev setup or production setup?

You might need to set "hostname": "http://localhost:8000" in site_config.json if there is no value for hostname


Hi @anand this is a frappecloud. Very strange I recently made a couple of changes to the report and on random orders it has this error. One thing I did was added Text Editor field to Sales Order Items doctype and we are putting an image in that field for 2 order items. That’s when it seemed to first occur but even if i remove one image from an item it still erorrs.

Can you try this? After attaching the image, save the form and they try to see print format.

Hi @anand I always save the form before printing but it doesn’t help. It’s only when the image is attached to the Sales Order Item - it works OK when attached to the Sales Order in the Text Editor field there. Not sure if that helps.

If I check the file path when it’s attached to the Sales Order I see:

<img src="/files/proof3635f6.PNG">

When I check the path when it’s attached to the Sales Order Item I see:

<img src="data:image/png;base64;filename=proof.PNG,iVBOR...uQmCC">

Is much more complicated path, why?


You have to save the document also.
Maybe your file did not get saved correctly. Can you try again.

I think the extract images from doc function works only on main doc and not children. Will have to fix this.


Fixed. Update and check :smile:

Fixed in V4 or V5 @anand?

V5. Please drop a mail on support and we will fast track your update to v5.

@rmehta @monojoker As replied on the support email, it’s fixed for v5. Do you want to upgrade?

Guys, we are OK to upgrade this weekend, whenever you have time. I will email support too. Users are happy to do so :smile: