PDF Generation issues

Hi there! I need help.
I have this error when I try to generate a PDF

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 58, in application
response = frappe.api.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/api.py”, line 49, in handle
return frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 19, in handle
execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 36, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 879, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/print_format.py”, line 50, in download_pdf
frappe.local.response.filecontent = get_pdf(html)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/pdf.py”, line 16, in get_pdf
pdfkit.from_string(html, fname, options=options or {})
File “/home/frappe/frappe-bench/env/src/pdfkit/pdfkit/api.py”, line 66, in from_string
configuration=configuration)
File “/home/frappe/frappe-bench/env/src/pdfkit/pdfkit/pdfkit.py”, line 38, in init
self.configuration = (Configuration() if configuration is None
File “/home/frappe/frappe-bench/env/src/pdfkit/pdfkit/configuration.py”, line 18, in init
[‘which’, ‘wkhtmltopdf’], stdout=subprocess.PIPE).communicate()[0].strip()
File “/usr/lib/python2.7/subprocess.py”, line 710, in init
errread, errwrite)
File “/usr/lib/python2.7/subprocess.py”, line 1223, in _execute_child
self.pid = os.fork()
OSError: [Errno 12] Cannot allocate memory

Greetings

First let me welcome you to the forum!

We always appreciate new users taking an active role in the discussions. Everyone here is like yourself. We are mostly fellow users that have been using ERPNext for various lengths of time and on different versions. The community here is fairly supportive and all we ask is that you pay it forward when you can by offering your own solutions to others when you might have figured out something that others may still be struggling to understand.

Please take time to read as much as you can. There is volumes of information here in the forum.

Now as for your current situation…

Since there are so many users on the forum that are using multiple different version of ERPNext, you would actually need to supply a bit more information before anyone could offer any help.

Info such as:

  • ERPNext version
  • Frappe version
  • Operating system (and version)
  • What size server are you using (# of CPU’s, and Memory)
  • And what you were specifically attempting to do when the error was triggered.

Since the major reported error was an operating system error, it may also mean that you do not have enough resources for your server to operate properly. However, that is a wild guess at this point because we do not have enough information.

Again, welcome aboard.

BKM :sunglasses:

Hello, thanks for the answer.

Here are my specifications.
ERPNext: v7.0.18
Frappe Framework: v7.0.15
Linux-Ubuntu 14.04
1 vCPU, 8GB storage
(Amazon EC2 t2micro)

About what I’m trying to do, when I click the PDF button to create/view a PDF of my invoices or quotes, the error is triggered.
This is the first time this error has occurred.

Greetings.

Hi @Joe_Aralem I have only used Frappe/ERPNext in v13, so I’m not entirely sure how things were done back in the v7 days. But nowadays at least, the PDF generation is handled by wkhtmltox and doesn’t work until it is installed. Do you have that package installed?

Hmmm… way back then I beleive it was handled with a very old python package called “pdfkit.py” and it is possible that the old pdfkit.py has been set to end of life and may no longer be supported.

It has been a very long time since I looked into it, but my gut feeling is this might be the case.

I am not sure how someone could go about getting it to work now.

BKM :nerd_face:

Thank you @trustedcomputer and @bkm
I’m not sure if I have that package installed.
Ummm, if “pdfkit.py” is deprecated, what can I do?
Search for that package?
Update version of erpnext?
If I update will I lose data?

Well I guess it depends on how high a priority the PDF generation is for you. Depreciated or not, you may be able to get “pdfkit.py” installed. Because really your whole stack is depreciated from the OS all the way up so the one more python package won’t make any difference as far as that goes.

Another approach would be to attempt to bring all your software current in stages in a new duplicated non-production server instance, but I think that’s beyond the scope of (and a lot more work than) what you were originally asking about even if that would be the most sustainable path in the long run.

Thanks @trustedcomputer
Understood,
You’re right, at the moment PDF is not mandatory, maybe in the near future, I will update my OS and ERP.

I appreciate the help.