问题
I need to merge multiple PDF files into one in my Heroku Cedar Rails app, and have settled upon using pdftk to do this.
I'm lost as to how to do this. I think the best approach would be to create a custom buildpack that includes a compiled binary for pdftk but I can't quite figure out how to get Vulcan to do this.
Is there a way to do this without Vulcan? Is there a pre-existing ruby buildpack that includes pdftk that I can use?
回答1:
I've got this working now, and a publicly available version of a custom Heroku Ruby buildpack with pdftk is here: https://github.com/millie/heroku-buildpack-ruby-pdftk
Be sure to see the instructions in the README.
Precompiled version of pdftk for Heroku's Cedar stack is available here: https://github.com/millie/pdftk-source
Hope this saves someone else some trouble!
回答2:
In case it's helpful to anyone here are the exact steps I followed to get millie's precompiled pdftk installed and working with my existing Cedar app. Your mileage may vary:
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"
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
heroku run bash
$ pdftk
回答3:
Using andedebauchery's excellent answer as a guide, I adapted these steps to get pdftk installed on my Heroku Node.js app from my Windows machine in September, 2015. The main differences between his steps and mine are:
I had to update the URL for the github repository from https://github.com/millie/pdftk-source.git to https://github.com/SirRawlins/pdftk-source
I had to download BSDtar in order to extract the executable from the pdftk.tar.gz (I tried GnuWin32 tar.exe first and it didn't work because it doesn't handle .tar.gz files)
I had to use
git update-index --add --chmod=+x pdftk
to grant execute permission on the file once it got to the remote Linux environment
Hopefully this will help other Windows developers in the future!
回答4:
This is how i setup pdftk in nodejs app in heroku
1- Create heroku app
heroku create
2- Set buildpack for pdftk
BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-apt
3- Set buildpack for nodejs
heroku buildpacks:add --index 1 heroku/nodejs
4 - Add the libgcj.so.* to your search path:
heroku config:set LD_LIBRARY_PATH=/app/bin
5- Turn on at least one dyno
heroku ps:scale web=1
6- Create a Procfile in the root of your project and define the following:
web: node server.js
5- Push changes in heroku
git push heroku master
来源:https://stackoverflow.com/questions/13545937/how-to-add-pdftk-to-heroku-cedar-app