Lets say you need to print some pages from a PDF file. But you don’t need to print the whole file, just a specific range, say pages 3 to the end of the document.
And let’s say you DON’T have any of those handy (and expensive) PDF libraries available. But of course you do have Acrobat Reader.
And let’s say you’ve got a whole pile of these PDFs that you need to get printed.
What to do?
First with the Printing
A little digging turned up that the AcroRd32.exe application (that actual Adobe Reader app, at least for version 9.x) can be invoked with command line parameters to print a file and exit:
AcroRd32.exe /p /h “filenamehere.pdf”
It’ll print to the current default printer, but that’s good enough for me for this purpose.
Simple enough, but you can’t specify which pages to print.
The Secret Ingredient
I’d almost given up on this when I came across a very handy utility called the PDFToolkit, by Sid Steward. PDFTK is a very small, free, command line driven utility. It won’t print, but it can slice and dice a PDF (or multiple PDFs) just about any which way you can dream up.
Say you have a PDF called input.pdf
You want to print pages 3 to the end of the file.
So, invoke PDFTK like so:
PDFTK.exe A=input.pdf cat A3-end output scratchfile.pdf
and then invoke the AcroRd32.exe line from above on the resulting scratchfile.pdf, and presto, your pdf is printed minus the first two pages!
Granted, if you’re developing a commercial product (or really even an inhouse utility), you’ll be much better served shelling out (no pun intended) a few bucks for a decent PDF library.
But in a pinch, PDFTK and AcroRd32 can be a pretty powerful little combination.