How to add pdftk to Heroku Cedar app?

前端 未结 4 2030
不思量自难忘°
不思量自难忘° 2021-02-01 10:06

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 bes

相关标签:
4条回答
  • 2021-02-01 10:15

    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!

    0 讨论(0)
  • 2021-02-01 10:33

    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

    0 讨论(0)
  • 2021-02-01 10:37

    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!

    0 讨论(0)
  • 2021-02-01 10:38

    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
    
    0 讨论(0)
提交回复
热议问题