python - 有人能够让 wkhtmltopdf 在 Heroku 上工作吗?
问题描述
我在 Heroku 上设置了一个 Python Flask 应用程序,它使用 pdfkit 将 .txt 文件转换为 .pdf 文件。pdfkit 在内部使用 wkhtmltopdf 作为依赖项。
我尝试了几个 wkhtmltopdf buildpacks,但无济于事。pdfkit 仍然无法在服务器上找到 wkhtmltopdf 二进制文件。最后一个使用:https ://elements.heroku.com/buildpacks/dscout/wkhtmltopdf-buildpack
我检查了 heroku 部署上的 /app/bin 文件夹,发现那里的二进制文件也可以正常工作。(我直接使用 wkhtmltopdf 二进制文件将字符串转换为 pdf)
我将该路径设置为操作系统环境参数,并使用二进制参数初始化 pdfkit,该二进制参数指向我在服务器上找到 wkhtmltopdf 的路径。
path_wkhtmltopdf = os.getenv("WKHTMLTOPDF_PATH")
config = pdfkit.configuration(wkhtmltopdf=path_wkhtmltopdf)
但同样,这不起作用。
我在 heroku-18 堆栈上运行。
解决方案
推荐阅读
- javascript - 我有一个 id 数组,如果没有,则需要更新对象文档 mongodb 中数组中的匹配对象,然后插入
- excel - 聚合和行函数跳转零值的问题
- ios - 在 CVImageBuffer 中缩放图像
- woocommerce - 拥有在线商店的公司有时会有两个网站吗?
- css - 在 Vue CLI 项目中更改作用域 CSS 时如何启用热模块重新加载?
- ios - 在一个 UIViewController 中切换 UIPickerViews 的问题
- javascript - 用 d3 以角度放大 svg
- ios - 创建自定义 cordova/phonegap 插件以使用 swift 库
- bash - 如何在bash脚本中使用if循环和for循环?
- excel - 如何使用 selenium/python 动态添加值