merge PDFs :)

Okay so I’ve searched and searched and found little bits of applescript, automator and Terminal commands to merge PDFs. The one I found to be simple and most adaptable and simple is causing and error and it’s due to the “joinPDF” command. Is there a good way to do this without automator or 3rd party software?

on open (theItems)
	set userDesktop to the path to desktop from user domain as text
	set output_name to (choose file name with prompt ¬
		"Enter output filename" default name userDesktop & "untitled.pdf") as string
	set UnixScript to "joinPDF " & "'" & (POSIX path of output_name) & "'"
	repeat with aFile in theItems
		set UnixScript to UnixScript & space & "'" & (POSIX path of aFile) & "'"
	end repeat
	do shell script UnixScript
end open

I do not have and have never used joinPDF, but if you installed it somewhere other than /usr/bin, /bin, /usr/sbin, or /sbin then you will probably need to specify the full path to the binary/script. Try something like set UnixScript to "/your/path/where/you/installed/joinPDF " & ..

Also you should consider using quoted form of instead of manually wrapping the string values with single quotes. Doing it manually mishandles the case where the string value already contains a single quote character. set UnixScript to "joinPDF " & quoted form of (POSIX path of output_name)

Model: iBook G4 933
AppleScript: 1.10.7
Browser: Safari Version 4 Public Beta (4528.17)
Operating System: Mac OS X (10.4)

Do you have Acrobat Professional? I am not familiar with JoinPDF but I am assuming it adds the pages from one to the end of the pages in the other PDF. You can script this in Acrobat. Here is the main part of a script I have to put 2 single page PDFs into one final 2-page PDF. You would need more code to set it up as a droplet and get the number of pages and all that. If you un-comment out the “with invisible” you won’t see the documents opening and closing.

tell application "Adobe Acrobat Professional"
	open file "Macintosh HD:Users:myUserName:Desktop:DocumentName_1.pdf" --with invisible
	open file "Macintosh HD:Users:myUserName:Desktop:DocumentName_2.pdf" --with invisible
	insert pages (document "DocumentName_1.pdf") after 1 from (document "DocumentName_2.pdf") starting with 1 number of pages 1
	save (document "DocumentName_1.pdf") to file "Macintosh HD:Users:myUserName:Desktop:DocumentName_Final.pdf"
	close front document without saving
	close front document without saving
end tell

EDIT:
Oh wait, I just realized you said without 3rd party software. Oh well, in case anyone else is interested…

Model: iMac Intel 10.5.5
Browser: Firefox 3.0.2
Operating System: Mac OS X (10.5)

Thank you Matt.

Yes I have Acrobat Pro. I’ll give this a try.

N