How to add pdftk to Heroku Cedar app?
Asked Answered
B

4

10

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?

Begorra answered 24/11, 2012 at 21:46 Comment(0)
B
12

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!

Begorra answered 26/11, 2012 at 16:22 Comment(1)
Do you mind if I add your version of pdfkit here to my post on using Vulcan to compile binaries for Heroku? ryandaigle.com/a/…Bugbee
S
11

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
Sandbox answered 31/7, 2013 at 20:26 Comment(2)
quick note to confirm that the above instructions from @Sandbox worked perfectly for me in February 2015.Springhouse
Thank you! And I can also confirm that these still worked in June 2015.Tubby
R
1

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:

  1. 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

  2. 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)

  3. 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!

Rapid answered 11/9, 2015 at 3:32 Comment(0)
H
0

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

Hay answered 18/10, 2016 at 6:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.