Problem with wkhtmltopdf and fonts Server error

Continuing the discussion from WKHTMLTOPDF Installing Fonts:

Hi, we installed the fonts as explained here:

We receive the following server error when trying to generate a pdf document with the preview api/method/frappe.templates.pages.print.download_pdf:

Traceback (innermost last):
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/app.py", line 52, in application
    response = frappe.api.handle()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/api.py", line 42, in handle
    return frappe.handler.handle()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py", line 66, in handle
    execute_cmd(cmd)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py", line 89, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/__init__.py", line 531, in call
    return fn(*args, **newargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/templates/pages/print.py", line 94, in download_pdf
    frappe.local.response.filecontent = get_pdf(html)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/utils/pdf.py", line 28, in get_pdf
    pdfkit.from_string(html, fname, options=options or {})
  File "/home/erpnext/frappe-bench/env/lib/python2.7/site-packages/pdfkit/api.py", line 68, in from_string
    return r.to_pdf(output_path)
  File "/home/erpnext/frappe-bench/env/lib/python2.7/site-packages/pdfkit/pdfkit.py", line 116, in to_pdf
    raise IOError('wkhtmltopdf reported an error:\n' + stderr.decode('utf-8'))
 IOError: wkhtmltopdf reported an error:
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 84: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 84: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 93: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 93: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 102: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 102: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 34: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 63: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 73: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 73: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 73: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 84: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 84: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 84: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 93: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 23: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 23: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 23: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 23: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 23: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 23: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 23: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 23: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 66: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 66: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 66: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 75: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 75: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/53-monospace-lcd-filter.conf", line 10: Having multiple values in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/65-droid-sans-fonts.conf", line 61: Having multiple values in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/65-droid-sans-fonts.conf", line 96: Having multiple values in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/90-fonts-nanum.conf", line 9: Having multiple values in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/90-fonts-nanum.conf", line 22: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/90-fonts-nanum.conf", line 22: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/90-fonts-nanum.conf", line 22: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/90-fonts-nanum.conf", line 26: Having multiple  in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/90-fonts-nanum.conf", line 31: Having multiple values in  isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/90-fonts-nanum.conf", line 40: Having multiple values in  isn't supported and may not work as expected
Loading pages (1/6)
[>                                                           ] 0%
[======>                                                     ] 10%
[=============>                                              ] 23%
Warning: Failed to load http://erp.betacoop.de/assets/frappe/css/bootstrap.css (ignore)
[============================================================] 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 2
[============================================================] Page 2 of 2
Done                                                                      
Exit with code 1 due to network error: ContentOperationNotPermittedError

Does http://erp.betacoop.de resolve to your ERPNext instance? If not,

then try running the following

bench update
bench setup nginx
sudo service nginx reload # might have to run as root

Yes, it is resolving to the ERPNext instance. the failed to load assets/frappe/css/bootstrap.css (ignore) we receive always. But this has nothing to do, right.?

From the server what is the output of curl -I http://erp.betacoop.de/assets/frappe/css/bootstrap.css
I haven’t ever seen ContentOperationNotPermittedError, could this be related to SELinux?

from the server where erpnext is installed we get:

HTTP/1.1 403 Forbidden
Date: Mon, 08 Dec 2014 14:43:41 GMT
Connection: close
Content-Type: text/html; charset=iso-8859-1

And from any computer:

HTTP/1.1 200 OK
Date: Mon, 08 Dec 2014 14:43:48 GMT
Server: nginx/1.6.2
Content-Type: text/css
Content-Length: 130312
Last-Modified: Thu, 27 Nov 2014 20:08:03 GMT
ETag: "547784a3-1fd08"
Accept-Ranges: bytes
Connection: close

Yes!!
So, it should be 200 OK from the server too. Now this is strange why it is 403. Can you check the nginx logs why it gives 403 from server?

We did also this to see if nginx user can access the file:

sudo -u nginx bash
cat /home/erpnext/frappe-bench/sites/assets/frappe/css/bootstrap.css

And it works, so the user nginx has permissions to read the file. But still we get the error.

Same issue am facing

ERPNext: v13.42.6 (HEAD)

Frappe Framework: v13.46.2 (HEAD)