当前位置: 动力学知识库 > 问答 > 编程问答 >

docker - Wkhtmltopdf in a Dokku app?

问题描述:

I have a NodeJS/Express Dokku container. I'm trying to use a node module which just runs the wkhtmltopdf command from shell, but it can't find wkhtmltopdf.

Anyone have any experience with this?

网友答案:

You need to check how wkhtmltopdf was installed in that image.

As mentioned in node-wkhtmltopdf issues 32:

The wkhtmltopdf command is executed as a shell command on non-Windows systems.
Make sure the /usr/local/bin directory is in your $PATH variable. Do this by running:

$ sh
sh-3.2$ which wkhtmltopdf    # Or try:
sh-3.2$ echo $PATH
sh-3.2$ exit

(In your case, you can do a sudo docker exec -it <containerIdOrName> sh)

The same issue adds:

What I ended up doing was downloading the dmg directly from wkhtmltopdf and that seemed to do the trick.

That means you might have to create a new image from the current one, installing wkhtmltopdf that way (with the dmg package)

jsonfry what installing wkhtmltopdf as a service container means: openlabs/docker-wkhtmltopdf-aas illustrates the installation process.

网友答案:

I got into the same issue as you did. I didn't want to run wkhtmltopdf in another container nor did I want to change the code to use remote calls. Since downloading wkhtmltopdf using apt-get plugin may result in a package that throws errors, I have created a new plugin that should set up wkhtmltopdf in the dokku container for you.

It is licensed using MIT license so feel free to do whatever you want. Hopefully it will help somebody.

URL: https://github.com/mbriskar/dokku-wkhtmltopdf

分享给朋友:
您可能感兴趣的文章:
随机阅读: