在Heroku上使用Wkhtmltopdf和Nodejs [英] Using Wkhtmltopdf with Nodejs on Heroku

查看:130
本文介绍了在Heroku上使用Wkhtmltopdf和Nodejs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是事情。我在nodejs上,我想用wkhtmltopdf生成一个PDF文件。
在本地工作正常,但是当我在heroku上推送它时,我有一个应用程序错误。

我认为这是因为它缺少一个用于Heroku的二进制Wkhtmltopdf ,你知道吗?
或者是其他东西?

解决方案

Heroku不包含 wkhtmltopdf code> binary,但你有两个选项可以在那里工作。



首先是 build wkhtmltopdf 源自Heroku (使用 Vulcan gem )。

二是直接捆绑 wkhtmltopdf 与您的应用。阅读这个 this and 这是的指导。实质上,您必须将二进制可执行文件下载到您的应用程序的 / bin 文件夹中,将其推送到Heroku,并正确配置 wkhtmltopdf 的设置。



PS我引用的例子与Ruby有关,但他们很好地概述了为了使Heroku工作需要设置 wkhtmltopdf 。有一个示例Rails应用程序 wkhtmltopdf 作为参考。


Here is the thing. I'm on nodejs and I want to generate a PDF file with wkhtmltopdf. It works fine locally, but when I push it on heroku I have an "Application Error".

I think it's because it's missing a binary Wkhtmltopdf for Heroku, do you know one? Or is it something else?

解决方案

Heroku doesn't include the wkhtmltopdf binary, but you have two options to get it working there.

First is to build wkhtmltopdf from source on Heroku (using the Vulcan gem).

The second is to directly bundle wkhtmltopdf with your app. Read through this, this and this for guidance. Essentially, you have to downloading the binary executable into your app's /bin folder, push it to Heroku, and correctly configure wkhtmltopdf's settings from within the app.

P.S. The examples I cited deal with Ruby, but they give a good overview of what needs to be set up for wkhtmltopdf to work on Heroku. There is a sample Rails app pre-integrated with wkhtmltopdf for reference.

这篇关于在Heroku上使用Wkhtmltopdf和Nodejs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆