I have to make a pdf out of some html pages in a containerized lambda. For this purpose I am trying to use pdfkit and wkhtmltopdf. I am not able to use it an d receiving the error as shown in picture-
Error text-
No wkhtmltopdf executable found: "./wkhtmltopdf"
If 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
My lambda code:-
import pdfkit as pdf
def lambda_function:
config = pdf.configuration(wkhtmltopdf='./wkhtmltopdf')
pdf.from_file(
filelist_new,
output_filename,
options={
'margin-top': '0.2in',
'margin-right': '0.2in',
'margin-bottom': '0.4in',
'margin-left': '0.2in',
'orientation': 'Landscape',
'page-size': 'A4',
'encoding': 'UTF-8',
'footer-line': '',
'footer-spacing': 1,
'footer-font-name': 'Times,serif',
'footer-font-size': '10'
},
configuration=config,
)
My docker file-
FROM umihico/aws-lambda-selenium-python:latest
RUN pip install pdfkit
RUN pip install boto3
RUN pip install wkhtmltopdf --target "./"
COPY lambda_function.py ./
CMD [ "lambda_function.lambda_handler" ]
and this is when I tried to find wkhtmlpdf by running the docker container:-