Heroku上的Pdftk安装

Heroku上的Pdftk安装

本文介绍了Heroku上的Pdftk安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在heroku堆栈上安装pdftk?

How to install pdftk on heroku stack?

由于其他依赖性,我无法将堆栈降级为Cedar,我需要在heroku-16上运行.

Because of other dependencies, I cannot downgrade stack to Cedar, I need to run on heroku-16.

推荐答案

答案为此处,如果它消失了,我只想将其存档以供后代使用.非常感谢Derek Barber!

Answer is here, I only want to archive it for future generations if it disappears. So special thanks to Derek Barber!

第一步是下载可在heroku上运行的pdftk二进制文件,并将其添加到您的Rails应用程序中:

The first step is to download a binary of pdftk that will work on heroku and add it to your Rails app:

mkdir -p [my_project]/vendor/pdftk/lib [my_project]vendor/pdftk/bin
cd /tmp
git clone https://github.com/millie/pdftk-source.git
cd pdftk-source
tar xzvf pdftk.tar.gz
mv bin/pdftk [my_project]/vendor/pdftk/bin/
mv lib/libgcj.so.12 [my_project]/vendor/pdftk/lib/
cd [my_project]
git add -f vendor/pdftk/
git commit -m "Add pdftk dependencies"

完成后,您可以将对heroku的更改向上推送,然后设置必要的环境变量,以便heroku知道在哪里可以找到这个新的二进制文件:

Once that is done you can push up your changes to heroku and then set up the necessary environment variables so that heroku knows where to find this new binary:

git push heroku master
heroku config:set LD_LIBRARY_PATH=/app/.heroku/vendor/lib:/app/vendor/pdftk/lib
heroku config:set PATH=/app/.heroku/python/bin:/usr/local/bin:/usr/bin:/bin:/app/vendor/pdftk/bin

最后,您可以尝试运行并通过运行bash并尝试将pdftk用于您的heroku实例:

Finally you can try it out and confirm that pdftk is now working on your heroku instance by running bash and trying it out:

heroku run bash
$ pdftk

如果pdftk工作正常,那么您应该会从pdftk中看到一堆帮助输出,这意味着您现在可以上手了.您已部署的应用程序应该能够使用pdf并生成精美填写的pdf表单.

If pdftk is working then you should see a bunch of help output from pdftk and that means you are now good to go. Your deployed app should be able to work with pdfs and generate beautifully filled out pdf forms.

这篇关于Heroku上的Pdftk安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 08:10