python-pdfkit icon indicating copy to clipboard operation
python-pdfkit copied to clipboard

Trouble Including wkhtmltopdf Binary in AWS Lambda Deployment Package

Open jorgesisco opened this issue 1 year ago • 0 comments
trafficstars

I'm encountering an issue where my AWS Lambda function cannot find the wkhtmltopdf executable despite it being included in the deployment package. The error thrown is:

Error processing message: No wkhtmltopdf executable found: \"\"\nIf this file exists please check
 that this process can read it or you can pass path to it manually in method call, check README. 
Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf

To resolve this, I've attempted the following without success:

  • Including the wkhtmltopdf binary in the deployment package via the pdfkit configuration.
  • Ensuring the binary exists in the expected path and has the correct permissions set (chmod +x).

Here's the relevant part of my code:

import os
import pdfkit

current_script_dir = os.path.dirname(os.path.realpath(__file__))
path_to_wkhtmltopdf = os.path.join(current_script_dir, "wkhtmltox-0.12.6-4.amazonlinux2_lambda/bin/wkhtmltopdf")
config = pdfkit.configuration(wkhtmltopdf=path_to_wkhtmltopdf)

I suspect I'm missing a step in the build or deployment process. I'm looking for guidance on how to ensure the wkhtmltopdf binary is correctly included in my Lambda function's deployment package and is discoverable at runtime. Any help or insight into what might be going wrong would be greatly appreciated.

jorgesisco avatar Dec 02 '23 10:12 jorgesisco