首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Azure函数中部署后wkhtmltopdf不工作

在Azure函数中部署后wkhtmltopdf不工作
EN

Stack Overflow用户
提问于 2022-05-21 18:59:44
回答 1查看 188关注 0票数 1

我有一个azure函数,它使用模块pdfkit python将html文件转换为pdf。

下面是部署的shell脚本,我在其中安装wkhtmltopdf,它是成功的。依赖性安装在usr/local/bin/wkhtmltopdf位置

代码语言:javascript
复制
echo "Starting Installation of wkhtlmtopdf for disclosure document generation..."
export DEBIAN_FRONTEND=noninteractive
apt update
apt install wget
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb -y
chmod -R a+rwx /usr/local/bin/wkhtmltopdf

这是我生成pdf的天蓝色函数代码

代码语言:javascript
复制
options = {
    'enable-local-file-access': None,
    'page-size': 'Letter',
    'margin-top': '0.75in',
    'margin-right': '0.75in',
    'margin-bottom': '0.75in',
    'margin-left': '0.75in',
    'encoding': "UTF-8",
    'custom-header': [
        ('Accept-Encoding', 'gzip')
    ],
    'no-outline': None
    }
    config = pdfkit.configuration(wkhtmltopdf='/usr/local/bin/wkhtmltopdf')
    pdfkit.from_file('index.html',
                    'output.pdf',
                    options=options,
                    configuration=config)

在部署函数之后,当测试时,它会显示以下错误

代码语言:javascript
复制
No wkhtmltopdf executable found: "/usr/local/bin/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

我在这里错过了什么?谢谢

EN

回答 1

Stack Overflow用户

发布于 2022-05-22 22:25:00

在部署平台时,使用了所有的代码,但没有带走可执行文件,这就是为什么它会产生错误,因此需要在azure函数根目录中添加可执行文件,然后安装它。

然后,我建议,将整个功能封装起来,然后将其部署在蔚蓝中。

有关如何使用docker部署azure函数,请参考以下文档

请参考加布里埃尔·库法罗的以下文章

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72332464

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档