Statically compile pdftk for Heroku. Need to split PDF into single page files

后端 未结 5 1211
暖寄归人
暖寄归人 2021-02-15 12:18

So we\'re using heroku to host our rails application. We\'ve moved to the cedar stack. This stack does not have the pdftk library installed. I contacted support and was told to

5条回答
  •  粉色の甜心
    2021-02-15 13:25

    We've encountered the same problem, the solution we came up with was to use Stapler instead https://github.com/hellerbarde/stapler, it's a python utility and only requires an extra module to be installed (pyPdf) on Heroku.

    I've been oriented to this blog entry: http://theprogrammingbutler.com/blog/archives/2011/07/28/running-pdftotext-on-heroku/

    Here are the steps I followed to install pyPdf:

    Accessing the heroku bash console

    heroku run bash
    

    Installing the latest version of pyPdf

    cd tmp
    curl http://pybrary.net/pyPdf/pyPdf-1.13.tar.gz -o pyPdf-1.13.tar.gz
    tar zxvf pyPdf-1.13.tar.gz
    python setup.py install --user
    

    This puts all the necessary files under a .local file at the root of the app. I just downloaded it and added it to our git repo, as well as the stapler utility. Finally I updated my code to use stapler instead of pdftk, et voilà! Splitting PDFs from Heroku again.

    Another way, probably cleaner, would be to encapsulate it in a gem ( http://news.ycombinator.com/item?id=2816783 )

提交回复
热议问题