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

后端 未结 5 984
滥情空心
滥情空心 2021-02-15 12:57

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 12:59

    The easy solution is to add the one dependency for pdftk that is not found on heroku.

    $ldd pdftk
        linux-vdso.so.1 =>  (0x00007ffff43ca000)
        libgcj.so.10 => not found
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f1d26d48000)
        libm.so.6 => /lib/libm.so.6 (0x00007f1d26ac4000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007f1d268ad000)
        libc.so.6 => /lib/libc.so.6 (0x00007f1d2652a000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00007f1d2630c000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f1d27064000)
    

    I put pdftk and libgcj.so.10 into the /bin directory of my app. You then just need to tell heroku to look at the /bin dir when loading libs.

    You can type

    $heroku config
    LD_LIBRARY_PATH:             /app/.heroku/vendor/lib
    LIBRARY_PATH:                /app/.heroku/vendor/lib
    

    To see what your current LD_LIBRARY_PATH is set to and then add /app/bin (or whatever dir you chose to store libgcj.so.10) to it.

    $heroku config:set LD_LIBRARY_PATH=/app/.heroku/vendor/lib:/app/bin
    

    The down side is that my slug size went from 15.9MB to 27.5MB

提交回复
热议问题