PDFtk works on CentOS 7 and 8!

Installing PDFtk on CentOS/RHEL/Scientific Linux 7

Update: This procedure works in CentOS/RHEL/Rocky/Oracle Linux 8!

In the transition to CentOS 7, the GNU compiler for the Java programming language libgcj was discontinued. This is partially due to it being dropped by the GCC suite. As it turns out, shared library linking of libgcj.so.10 from CentOS 6 is binary compatible with PDFtk. We use PDFtk in our office for collating documents that have been scanned, and it works great!

After searching online and finding lots of links with various levels of success and server admins having used PDFtk for over a decade, we decided to package it and provide it to the community.

Installation is simple, depending on your architecture:

x86_64

yum localinstall https://www.linuxglobal.com/static/blog/pdftk-2.02-1.el7.x86_64.rpm

i686

yum localinstall https://www.linuxglobal.com/static/blog/pdftk-2.02-1.el7.i686.rpm

After  Updating

If you are reading this article, then you probably just upgraded your system. Now would be a great time to consider security for your application and server infrastructure. There are many services that we offer including support, security, maintenance, monitoring, backups, and live SQL backup replication. We even offer a security hardened hosting environment!

Please let us know if you have any issues with these packages or if we may be of service!

Update: 2017-01-26

Some have asked for the .spec that we are using. Really are we are doing is repacking libgcj.so.10* which we pulled out of CentOS 6 libgcj-4.4.7-17.el6. PDFtk was downloaded as an RPM from their site unmodified except that we converted it to a tar and added libgcj. You may need to edit the spec to make it build on your system, but it works in our build environment: https://www.linuxglobal.com/static/blog/pdftk.spec

-Eric

45 thoughts on “PDFtk works on CentOS 7 and 8!

  1. I had pdftk working on centos 7 for awhile but somehow my yum update broke. I had used the previous method of:

    rpm -ivh –nodeps libgcj-4.4.7-16.el6.x86_64.rpm
    yum install pdftk-2.02-1.el6.x86_64.rpm

    and it was working. All of a sudden it’s now crashing, giving me these errors. I tried your install and the same thing is happening:

    ./test.sh
    Unhandled Java Exception in create_output():
    java.lang.ClassCastException: pdftk.com.lowagie.text.pdf.PdfNull cannot be cast to pdftk.com.lowagie.text.pdf.PdfDictionary
    at pdftk.com.lowagie.text.pdf.FdfReader.readFields(pdftk)
    at pdftk.com.lowagie.text.pdf.FdfReader.readPdf(pdftk)
    at pdftk.com.lowagie.text.pdf.PdfReader.(pdftk)
    at pdftk.com.lowagie.text.pdf.PdfReader.(pdftk)
    at pdftk.com.lowagie.text.pdf.FdfReader.(pdftk)

    Any idea what’s wrong? I can no longer get pdftk to work. I’m using it for fdf merging.

  2. Here’s another version of the error I get depending upon how I call pdftk whether I do so with an implicit path or not:

    #pdftk test.pdf fill_form test.fdf output testout.pdf

    Unhandled Java Exception in create_output():
    Unhandled Java Exception in main():
    java.lang.NullPointerException
    at gnu.gcj.runtime.NameFinder.lookup(libgcj.so.10)
    at java.lang.Throwable.getStackTrace(libgcj.so.10)
    at java.lang.Throwable.stackTraceString(libgcj.so.10)
    at java.lang.Throwable.printStackTrace(libgcj.so.10)
    at java.lang.Throwable.printStackTrace(libgcj.so.10)

    I have uninstalled libgcj and pdftk and re-installed multiple times.. I’ve been wrestling with this for days and cannot figure out how the system broke… any help is most appreciated

  3. Actually I found what my problem was – pdftk was working properly, although it will throw and error and crash if you try a fill_form command and there’s unbalanced parenthesis in any of the field values.

  4. Thank you so much! In May-June I had scoured the Internet for a solution for Fedora 28. Wasn’t aware you people had looked into it in August. Very glad you did.

  5. Still very useful even in 2019. I hope you will do a version for Centos 8.0 as well as soon as it is released. If there was a Donate button I definitely would.

  6. Thanks so much! FWIW, it looks like this works for RHEL 6 and RHEL 8 as well. So, if you work on servers with various RHEL distros, you can just use this one command on all.

  7. Quick shout out on this post. It helped me help a local non-profit. Just goes to show you that you never know how sharing knowledge will touch and affect others.

  8. Thank you. I got this to work on a shared server on BlueHost. They upgraded me to CentOS7, which broke pdftk for me. When I called they said it wasn’t possible to install on CentOS7.

    To make it work I renamed pdftk to pdftk.target. I then created a script I named pdftk to point to the pdftk.target which has the path to the libgcj.so.10 file.

    #!/bin/bash
    export PATH=~/usr/bin:$PATH;
    export LD_LIBRARY_PATH=~/lib:~/usr/lib64:$LD_LIBRARY_PATH;
    ~/usr/bin/pdftk.target “$@”

    • Hi Gardiner,
      I’m also using shared hosting on Bluehost but I have not been able to get pdftk installed. Any assistance you can provide would be greatly appreciated. Thanks

  9. pdftk on CentOS 8 ? Just rpm -ivh pdftk-2.02-1.el7.x86_64.rpm

    After install, you will have pdftk also working in CentOS 8 (although the RPM is for CentOS 7…).

    Thank you for saving my day upgrading from CentOS 7 to CentOS 8.

  10. It is 2022 and it still helped me. The pdftk-java provided with my CentOS 7.9 took 2.5 minutes for a job instead of 34 seconds as it is the case with the gcj-Version.

    T H A N K Y O U

Leave a Comment