Solution: combining PDFs using RunRev on Mac OS X

Bruce A. Pokras macstacks at earthlink.net
Sat Oct 21 11:02:03 EDT 2006


Hello group,

A couple of times I and others have asked about a way to combine PDF 
files using a RunRev script. I don't recall ever seeing an answer, so 
I would like to share the solution that I found.

There is an Automator action under OS X that combines PDFs. Someone 
on an Automator mailing list looked into that action and found that 
it was run by a fairly simple Python script. Since Python scripts can 
be run from the Shell, it was fairly straight forward to adopt that 
to RunRev. Here is the actual commnad:

get shell("python '/System/Library/Automator/Combine PDF 
Pages.action/Contents/Resources/join.py' -o" && outputFile && 
inputFiles

outputFile is the full path to the file you are creating that 
contains all the PDF pages. It must be surrounded by single quotes. 
E..g., '/Bruce/Documents/Patents/5000000.pdf'

inputFiles is a list of full paths to the files you are combining 
with each full path surrounded by single quotes and each separated 
from the other by a space. E.g., 
'/Bruce/Documents/Patents/5000000/5000000-001.pdf' 
'/Bruce/Documents/Patents/5000000/5000000-002.pdf' 
'/Bruce/Documents/Patents/5000000/5000000-003.pdf' 
'/Bruce/Documents/Patents/5000000/5000000-004.pdf'

The one "gotcha" is that a shell command cannot have more than 1024 
characters. So if you want to combine a lot of pages, you will need 
to incrementally add files to the outputFile. This means naming 
outputFile as one of the inputFiles for the second through last 
loops. You could add one page at a time to the outputFile or as many 
as possible (per my above example), but I have found that adding one 
page at a time to be much slower than adding as many as possible 
through each iteration.

Does anyone know in which version of OS X the "Combine PDF pages" 
Automator action was introduced?

Theoretically, the free pdftk PDF tool would allow RunRev Windows 
apps to do this, also. I will be trying that out once my OS X app is 
completed.

Regards,

Bruce Pokras
Blazing Dawn Software
www.blazingdawn.com




More information about the use-livecode mailing list