My adventure with pdftk

by brian d foy

I'm writing this as I try to install pdftk, which Sid Steward uses quite a bit in PDF Hacks. I have a lot of time between steps.

First, I went to the pdftk site. The documentation for the program looks great, and the program looks useful. I want it.

Not so fast, cowboy. He says "Mac OS X users must build and install GCJ, first." Eh? There is even a reference to special build instructions from John M. Gabriele. GCJ doesn't come with Mac OS X.

Well, I need to get GCJ I guess. Not so fast there, either. After looking around the GCJ page and discovering that the download page does not have links to anything I need to download (like GCJ), I finally find a mirror site for GCC. Yep, I need to download all 34 MB of it. It's downloading right now. (17 minutes)

Why do I need all this? I think this sums it up: "Pdftk is also an example of how to use a library of Java classes in a stand-alone C++ program." I just want to play with PDF files and try some of the things in this book. I don't care about Java or C++. In fact, I'm wondering why I even have to know that. At this point I'm just some dumb consumer, but I have to worry about all this other stuff.

I'm following John's instructions, so I'm building gcc with "make bootstrap". That's running right now. time passes. It's still running. He says "On my 500 MHz G3 Powerbook with 256 MB of memory, that step took about 4 hours." I've got a G4 Powerbook, but still, this is taking a while.

After an hour and a half, the compilation aborts with an error. Ugh.

It's the same error that John points out in his instructions. Ed Smith-Rowland reported the bug, and Trevor Harmon pointed out a faulty header file from OpenOffice (why did I even bother installing that?), which is also mentioned in the fink FAQ and elsewhere.

I remove the offending file. Maybe I should have just moved it out of the way. Nah, I'm feeling mean. Kill it! Die file die!


$ sudo rm /usr/local/include/dlfcn.h


I start over. Well, not really. Most of the work is already done and make(1) can pick up where it left off, or at least I think it does, but it's running configure. Hmmm... it looks for there are even more subdirectories with even more stuff to install.

I start listening to yesterday's Marketplace, and the teaser is someone saying "I look at my reader as someone whose not stupid at all. Even if they're not a techie, they're smart, they have a life, and this stuff should just work for them." Preach it brother. It turns out that the teaser is from Walt Mossberg of the Wall Street Journal, and I'm surprised that I like something that he said since I haven't liked the few columns of his that I have read. The gcc compilation is still going. I check out some of Mossberg's columns. I don't like with reviews of the iPod, but other things seem okay.

My cat comes in and curls up among the cables under my desk, and the gcc compilation is still chugging away. Marketplace ended, so I'm listening to All Things Considered now. This is often how I measure work time: how many public radio programs I listen to.

As I wait, (why am I waiting?), I write an article for next month's The Perl Journal, and I occasionally check in on the compilation. All I wanted was pdftk, I remember. This started so innocently. I start to think that I might have been able to re-implement pdftk in perl faster than it takes to install it. Sid does mention Perl a couple times in the book, and one of the hacks is about PDF::API2, but I also remember that I tried this before and never finished it because the module interface was a bit too low-level to be immediately useful.

An hour later, it looks like the gcc compilation has finished successfully. I install it. It installs a lot of things that I will probably never use for anything. This takes a while too, but not quite as long as the compilation.

I download the pdftk 1.0 src and start to compile that. The documentation mentions adjusting some Makefile parameters, but I just go for the defaults. Boy does that compile a lot of things. This thing better work.

It finishes compiling after a couple of minutes, but I pause before trying it out. I hope I haven't wasted all of this effort. I run it with no arguments, and I get the help summary. Well, at least it doesn't blow up.

Okay, now for the test. I want to append one PDF file to another. Things like PDFmerge and texexec haven't been able to do the job. For some reason they both mess up the page rotation.

Lo and behold, after all that, it just works. Thank god.

5 Comments

aristotle
2004-08-28 05:10:23
It has a name
Yak Shaving
sid_steward
2004-08-31 09:45:37
binary gcj on OS X
I have been looking for gcj/libgcj binaries for OS X that folks could install. Please e-mail me (sid at accesspdf.com) with recommendations.


Precompiled binaries of pdftk are available for many platforms. If you have trouble compiling pdftk on your platform, please e-mail me and I'll help.


If you successfully compile pdftk on a new platform, please e-mail me with your Makefile so I can post it online.


Thanks-


Sid Steward
maintainer: pdftk

sid_steward
2004-09-20 15:39:17
pdftk installer for OS X available

Here is an e-mail I received the other day from Scott Lasley:

(snip)

Hello,

I saw your pdftk site mentioned on the Oreilly PDF Hacks page. I was able to compile gcj and pdftk using the information on John M. Gabriele's web site you mentioned. I created an OS X installer package for pdftk that includes the needed libgcc, libgcj and libstdc libraries. I have used it to install pdftk on two macs running 10.3.5, and the program seems to work on both systems. That has been the extent of my testing. I don't know if the program will work on systems older than OS X 10.3.


The installer is here if you want it


http://home.earthlink.net/~selasley/pdftk1.0.dmg.gz

(snip)


Please send any feedback to me, Sid Steward: sid at accesspdf dot com.

Cheers-

Sid Steward

maintainer: pdftk

sid_steward
2004-11-05 16:02:17
pdftk 1.11 installer for OS X 10.3 available
Scott Lasley recently created a pdftk 1.11 installer for OS X 10.3. Download this installer from:


http://www.accesspdf.com/pdftk/#packages


To see the changes I made from pdftk 1.00 to 1.11, visit the Version History section:


http://www.accesspdf.com/pdftk/#history


Cheers-


Sid Steward
maintainer: pdftk


a11en
2005-11-23 16:20:12
Completely agree!
Why use relatively esoteric compilers etc., when the majority of users will not have these tools? A prime example of this is the use of .net for things that GTK can do wonderfully on the windows side. Why do I need to install/run .net for a simple program?


Personally, I stay away from java as much as I possibly can. Have you tried out the latest incarnations of Matlab? They're slow as a dog on most hardware- it appears they run slower than my old Mac IIfx with the old version of matlab! Is this move to Java really beneficial to the end-user?


Oh well, thanks for the heads-up on this one. I'll be avoiding pdftk.


ps- for concatenation, almost the same can be done in pdflatex/pdftex in relatively few lines... and texexec rudamentarily with: texexec --pdfarrange --result=doc3.pdf doc1.pdf doc2.pdf ...