pdftk 1.41 for Mac OS X 10.6

Important update: If you’ve downloaded the package before and you’re experiencing “segmentation fault”s with certain PDF files, please download the updated package below. Thanks to commenter Azhrei, we were able to fix a problem with one of the libraries, and all should work fine now!


Due to my being a remote employee, I get to juggle with PDF files quite a bit. A great tool for common PDF manipulations (changing page order, combining files, rotating pages etc) has proven to be pdftk. Sadly, a current version for Mac OS X is not available on their homepage. In addition, it is annoying (to say the least) to compile, which is why all three third-party package management systems that I know of (MacPorts, fink, as well as homebrew), last time I checked, did not have it at all, or their versions were broken.

Now I wouldn’t be a geek if that kept me from compiling it myself. I took some hints from anoved.net who was nice enough to also provide a compiled binary, but sadly did not include the shared libraries it relies on.

Instead, I made an installer package that’ll install pdftk itself as well as the handful of libraries you need into /usr/local. Once you ran this, you can open Terminal.app, and typing pdftk should greet you as follows:

$ pdftk
SYNOPSIS
       pdftk <input PDF files | - | PROMPT>
            [input_pw <input PDF owner passwords | PROMPT>]
            [<operation> <operation arguments>]
            [output <output filename | - | PROMPT>]
            [encrypt_40bit | encrypt_128bit]
(...)

You can download the updated package here: pdftk1.41_OSX10.6.dmg

(MD5 hash: ea945c606b356305834edc651ddb893d)

I only tested it on OS X 10.6.2, if you use it on older versions, please let me know in the comments if it worked.



Categories: Mozilla Crosspost, OSU OSL Crosspost, Tech Talk | Tags: , ,

52 Responses to “pdftk 1.41 for Mac OS X 10.6”

Pages: « 1 [2] 3 » Show All

  1. Hi,
    I installed this package, but there was no pdftk in this path:
    /usr/local/bin
    that means:
    $ ls /usr/local/bin/ | grep pdf
    dvipdf
    pdf2dsc
    pdf2ps
    pdfopt
    ps2pdf
    ps2pdf12
    ps2pdf13
    ps2pdf14
    ps2pdfwr

    What do I do?
    Thanks

  2. alamati: Oh no, I made a typo :( I apologize. If you download the package again and reinstall, it should work!

  3. Since you appear to know how to compile pdftk on Snow Leopard, would you please inform those of us with the MacPorts project how you did it, so that I can fix the MacPorts pdftk port? Thanks.

  4. Essentially, compile gcc including gcj, then compile pdftk against it. Curiously, I now seem to be unable to compile the version of gcc anymore that I thought I used the last time (4.2.1)… fail.

    Also, the self-compiled version led to some segfaults in libstdc++, while using the library belonging to OS X did not have that problem (see comment 17).

    Sadly, I am not sure how easy it’ll be to use that knowledge for MacPorts.

  5. [...] Stop the insanity. Install pdftk without the baggage. – Link [...]

  6. Thanks for the dmg, saved me lots of time.

  7. [...] the blog fredericiana you can find a dmg installer containing a precompiled distribution of pdftk with all libraries [...]

  8. Sweet, merci merci!

  9. Thank you were much! What a relief!

  10. I was really excited to see this package put together – thanks! I’m having a problem, though.

    Everything seems to run fine from the command line, but I am getting this error when trying to build a pdf that (I assume) has images in it:

    dyld: _dyld_bind_fully_image_containing_address() error
    dyld: Symbol not found: _iconv
    Referenced from: /usr/local/gcj/lib/libgcj.8.dylib
    Expected in: flat namespace

    Any ideas??

  11. I get this when I run otool. Notice the second line of output. You might check yours:

    $ otool -L /usr/local/bin/pdftk
    /usr/local/bin/pdftk:
    /usr/local/gcj/lib/libgcj.8.dylib (compatibility version 9.0.0, current version 9.0.0)
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
    /usr/local/gcj/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
    /usr/local/gcj/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.0)

  12. Thank you for doing this! I just migrated over to Snow Leopard a month ago and have been frustrated in not being able to get pdftk back.

    I’ll keep an eye on your Stapler project too — what’s the current level of functionality?

  13. Hey Roger, glad you like it. The Stapler project is pretty functional by now: You can see the current functionality in its README file.

    I’d like to compile it into a binary package (.exe file for Windows, or binary for Linux/Mac) but that’s easier said than done with a Python project ;) Instead, I might add a setup.py, allowing you to install and uninstall it with pip.

  14. Thanks so much!!!

  15. Downloaded and installed without error on 10.6.4. Unfortunately it bombs when run with this command: pdftk SM-2005-0066-NA_CS2100_SE07.pdf dump_data output report.txt

    Here is the failure log:

    Process: pdftk [14035]
    Path: /usr/local/bin/pdftk
    Identifier: pdftk
    Version: ??? (???)
    Code Type: X86 (Native)
    Parent Process: bash [13996]

    Date/Time: 2010-06-25 16:05:26.597 -0400
    OS Version: Mac OS X 10.6.4 (10F569)
    Report Version: 6

    Interval Since Last Report: 505884 sec
    Crashes Since Last Report: 10
    Per-App Crashes Since Last Report: 2
    Anonymous UUID: E4157C0E-0CB2-4450-818F-8775EA2DAECA

    Exception Type: EXC_BAD_ACCESS (SIGSEGV)
    Exception Codes: KERN_INVALID_ADDRESS at 0x0000000036ad837f
    Crashed Thread: 0 Dispatch queue: com.apple.main-thread

    Thread 0 Crashed: Dispatch queue: com.apple.main-thread
    0 libstdc++.6.dylib 0x05ff6c9f std::ostream::flush() + 17
    1 libstdc++.6.dylib 0x05ff6d4b std::ostream::sentry::sentry(std::ostream&) + 53
    2 libstdc++.6.dylib 0x05ff716f std::basic_ostream<char, std::char_traits >& std::__ostream_insert<char, std::char_traits >(std::basic_ostream<char, std::char_traits >&, char const*, int) + 36
    3 pdftk 0x0001b967 ReportOnPdf(std::ostream&, com::lowagie::text::pdf::PdfReader*) + 1527
    4 pdftk 0x0000de3b TK_Session::create_output() + 11355
    5 pdftk 0x000132c6 main + 582
    6 pdftk 0x00002c09 _start + 208
    7 pdftk 0x00002b38 start + 40

    Thread 1:
    0 libSystem.B.dylib 0x985e7066 __semwait_signal + 10
    1 libSystem.B.dylib 0x985e6d22 _pthread_cond_wait + 1191
    2 libSystem.B.dylib 0x985e89b8 pthread_cond_wait$UNIX2003 + 73
    3 libgcj.8.dylib 0x0045bcc2 _Jv_CondWait(_Jv_ConditionVariable_t*, _Jv_Mutex_t*, long long, int) + 626 (PersistenceDelegate.java:60)

    Thread 0 crashed with X86 Thread State (32-bit):
    eax: 0x36ad838b ebx: 0×00160000 ecx: 0×00160000 edx: 0×00000000
    edi: 0x062dc858 esi: 0xbfffded8 ebp: 0xbfffde88 esp: 0xbfffde70
    ss: 0x0000001f efl: 0×00010282 eip: 0x05ff6c9f cs: 0×00000017
    ds: 0x0000001f es: 0x0000001f fs: 0×00000000 gs: 0×00000037
    cr2: 0x36ad837f

    Binary Images:
    0×1000 – 0x2b2fe7 +pdftk ??? (???) /usr/local/bin/pdftk
    0×454000 – 0x12a1fff +libgcj.8.dylib 9.0.0 (compatibility 9.0.0) /usr/local/gcj/lib/libgcj.8.dylib
    0x5fce000 – 0x6038fe7 +libstdc++.6.dylib 7.9.0 (compatibility 7.0.0) /usr/local/gcj/lib/libstdc++.6.dylib
    0×6093000 – 0x609aff3 +libgcc_s.1.dylib ??? (???) /usr/local/gcj/lib/libgcc_s.1.dylib
    0x8fe00000 – 0x8fe4162b dyld 132.1 (???) /usr/lib/dyld
    0x94b7e000 – 0x94c72ff7 libiconv.2.dylib 7.0.0 (compatibility 7.0.0) /usr/lib/libiconv.2.dylib
    0×96466000 – 0x96469fe7 libmathCommon.A.dylib 315.0.0 (compatibility 1.0.0) /usr/lib/system/libmathCommon.A.dylib
    0x985b8000 – 0x9875efeb libSystem.B.dylib 125.2.0 (compatibility 1.0.0) /usr/lib/libSystem.B.dylib
    0xffff0000 – 0xffff1fff libSystem.B.dylib ??? (???) /usr/lib/libSystem.B.dylib

    Model: MacPro1,1, BootROM MP11.005C.B08, 4 processors, Dual-Core Intel Xeon, 3 GHz, 6 GB, SMC 1.7f10
    Graphics: ATI Radeon X1900 XT, ATY,RadeonX1900, PCIe, 512 MB
    Memory Module: global_name
    Bluetooth: Version 2.3.3f8, 2 service, 19 devices, 1 incoming serial ports
    Network Service: Ethernet 1, Ethernet, en0
    PCI Card: ATY,RadeonX1900, Display, Slot-1
    Serial ATA Device: ST3500320AS, 465.76 GB
    Serial ATA Device: ST31500341AS, 1.36 TB
    Serial ATA Device: KINGSTON SNV425S2128GB, 119.24 GB
    Serial ATA Device: ST31000333AS, 931.51 GB
    Parallel ATA Device: OPTIARC DVD RW AD-7170A
    Parallel ATA Device: PIONEER DVD-RW DVR-112D
    USB Device: Cinergy HT USB PVR (US), 0x0ccd, 0×0075, 0xfd300000
    USB Device: CP2102 USB to UART Bridge Controller, 0x10c4 (Silicon Laboratories, Inc.), 0xea60, 0x3d200000
    USB Device: Bluetooth USB Host Controller, 0x05ac (Apple Inc.), 0×8206, 0x5d200000
    USB Device: Hub in Apple Pro Keyboard, 0x05ac (Apple Inc.), 0×1003, 0x5d100000
    USB Device: Apple Optical USB Mouse, 0x05ac (Apple Inc.), 0×0304, 0x5d120000
    USB Device: Apple Pro Keyboard, 0x05ac (Apple Inc.), 0x020b, 0x5d130000
    FireWire Device: built-in_hub, Up to 800 Mb/sec

  16. PDFtk is back on the Mac! Thank you.

  17. [...] PDFtk: скачать скомпилированную версию PDFtk, а также сам рабочий процесс. Проверено только в [...]

  18. [...] building pdftk from either MacPorts or Fink is currently broken so there is a precompiled version here. I only tested it on OS X 10.6.2, so if you use it on other versions, please let me know in the [...]

  19. Apologies in advance for a nitpicky question – I am trying to produce and flatten forms (so they can go straight to the iPhone) and the font in the filled in form fields never seems to come out right. It just defaults to Helvetica font, even if I embed the fonts or choose other fonts I know are in the systems. If I load the FDFs in Adobe Reader everything looks good, but if I flatten on my computer the same thing happens. Any ideas on getting the merge to obey the formatting already on the forms fields?

    Thanks for your work which has already been a big help!

  20. almost….

    Does not run on pre 10.6 versions. Pity, it was a good piece of work. Thanks anyway

    Looks like I’m in for a long debug. What a mess eh? Something that “just works” on a Linux distro can be such a pain on a Mac.

  21. “Does not run on pre 10.6 versions.” — not too surprising, the versions are all different, which is why this blog post says the build is for 10.6.

    I agree though that it should be easier to build for sure. Would be nice if it was.

  22. It really needs an autoconf configuration built for it. Alas, I don’t know autoconf right now and I’m so busy with another open source project that I can’t spend the time to learn it. In fact, Fred did much better than I as I never got it to build in the first place. :(

    Worst case would at least be a makefile with an “all” target that did everything necessary for a particular version. For example, “all10-6″ could build it for 10.6 and “all10-5″ would build it for 10.5. Then the top-level “all” target could check the OS level and run “$(MAKE) all10-$level” or something similar…

  23. The problem is that a proper build it ridiculously hard to reproduce. At the time of building this I had an “organically grown” macports instance on my Mac (which is long gone, now that I use homebrew), and now I have trouble reproducing the build. I’ll try it again one of these days. In fact, if it was reproducible, we could just submit it to homebrew and call it good.

  24. Note that Fink now has pdftk-1.41 available for 10.6 (it needed gcc45 to provide a gcj that works on 10.6).

  25. Hot, thanks! Might be able to snag that and make a homebrew “Formula” from it.

Pages: « 1 [2] 3 » Show All

Leave a Reply

Comments will be closed on August 10, 2011.