我正在使用AWS Lambda使用ninja2模板生成pdf文件。我正在尝试使用pdfkit将我的超文本标记语言转换为pdf。我意识到pdfkit有一个内部依赖项- wkhtmltopdf,它需要作为二进制文件使用或通过包管理器安装。我不确定如何在AWS Lambda上实现此功能?
使用我当前的模板和使用pdfkit的python代码,我得到以下错误-
{
"errorMessage": "No wkhtmltopdf executable found: \"b''\"\nIf this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf",
"errorType": "OSError",
.....
.....
}关于如何让pdfkit在lambda上工作,有什么想法吗?
对wkhtmltopdf的替代有什么建议吗?
谢谢
发布于 2020-02-14 19:33:22
我用layer做了一个简单的演示,演示了如何通过无服务器框架来使用PDFKit。检出https://medium.com/@crespo.wang/create-pdf-using-pdfkit-on-serverless-aws-lambda-with-layer-721ca86724b2
发布于 2019-12-30 02:04:23
AWS Lambda具有层的概念,允许您将您的自定义依赖项作为zip上传,然后它将在安装到盒子上时可用。有关更多信息,请参阅此处:
https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html
在您的例子中,您可以上传wkhtmltopdf的二进制文件作为层,并且在创建lambda函数时,您可以提供要使用的层。
发布于 2019-12-30 01:11:17
GitHub上有多个项目用于在Lambda上运行wkhtmltopdf,例如:
https://github.com/lubos/aws-lambda-wkhtmltopdf
https://stackoverflow.com/questions/59521458
复制相似问题