Can I use wkhtmltopdf on AWS Lambda

greeting,

I use the AWS Lambda function to merge PDF files stored on S3. In addition, I need to create a PDF file (from HTML and CSS). I tried using wkhtmltopdf, but it seems to me that I will need to install it using apt-get install (which I donโ€™t think I have access to AWS Lambda).

Any ideas on how I can do this?

Any suggestions for replacing wkhtmltopdf?

Thanks!

+7
source share
5 answers
+9
source

Include the wkhtmltopdf binary and make sure it has execute permission (chmod 755). Add the binary path to the runtime language. e.g. with nodejs

process.env['PATH'] = process.env['PATH'] + ':' + process.env['LAMBDA_TASK_ROOT'] + '/bin/linux'; 
+9
source

Download the binary file inside the folder of your project, for example, in the "binary /" folder, so that during lambda execution you can call it via the link

+5
source

This one works like an HTTP API. You just need to configure the API gateway for your lambda:

https://github.com/adleritech/aws-lambda-wkhtmltopdf

Request:

 { "htmlBase64" : "PGJvZHk+SGVsbG8gd29ybGQ8L2JvZHk+" } 

Response:

 { "pdfBase64": "..." } 

Or you can pass the URL:

 { "url" : "http://google.com" } 
+1
source

Source: https://habr.com/ru/post/1264036/


All Articles