1

I have a cloud function that generates a pdf. The cloud functions is in Python3.7 and it uses the module pdfkit==0.6.1. This pdfkit has a dependency of wkhtmltopdf. The OS env where the instance is running does not provide this dependency. So what i did was put the wkhtmltopdf binary in the code directory and use it from there. The problem is that it gives an error "[Errno 13] Permission denied: '/user_code/wkhtmltopdf.deb'". Is there a way to allow permissions to a file in cloud functions? or maybe install the dependency another way like so "sudo apt-get install xvfb libfontconfig wkhtmltopdf

user550468
  • 13
  • 3
  • `wkhtmltopdf.deb` is not a binary. It is a Debian installation package. Cloud Functions is not an operating system. Dependencies need to be specified in the `requirements.txt` file. I do not use this package so I cannot answer how to use it in Cloud Functions. – John Hanley Dec 01 '19 at 18:59

1 Answers1

1

Cloud Functions is a Event-driven serverless; this means that a function will run when an event occurs and you don't care about the infrastructure behind. pdfkit depends on wkhtmltopdf which is a binary that should be installed on your server that does not apply for Cloud Functions scope.

Nevertheless, I tried to upload the binaries to Cloud Functions zipped with the code and after doing some tricky commands using python changing the permission of the binaries to be executable you need to face another problem, wkhtmltopdf depends on QT5 libraries. You need to upload your zip file with the binaries, libraries and your code which is more than 150 MB and even when you thought you're done, more libraries are required, more memory is needed and when you execute your function it takes a long time to run because of all the preprocessing.

At the end, this is a bad idea and you may want to use an alternative like this.