Combine all open PDFs in Preview into one PDF


Not sure where to start with this one. But a common situation. I open bunch of PDFs attached to emails in Preview. I then want to combine all these PDFs into one PDF. As they are already open, easiest way would be to have preview open a new PDF with all other PDFs incorporated. I just save new PDF. You can do this by dragging into windows in Preview but when you have 10 PDFs, this is a pain!

Is there not a simple command to send to Preview saying concatenate all open files?



This should give you a headstart! I can’t recollect where I’ve got it from, but it has been working well for me. It uses Python and I believe it does not require any installation. Try it!

property join_py : quoted form of "/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/"
tell application "Finder"
	set add_pdfs to ""
	set output_pdf to POSIX path of ("Macintosh HD:Users:michael:Desktop:LBPfinal2.pdf" as Unicode text)
	set Afolder to "Macintosh HD:Users:michael:Desktop:LBP2" as alias
	set these_items to every item of folder Afolder
	repeat with an_item in these_items
		set add_pdfs to add_pdfs & space & quoted form of (POSIX path of (an_item as alias))
	end repeat
	do shell script "python " & join_py & " -o " & (quoted form of output_pdf) & add_pdfs
end tell


Thanks Michael

I see how this works. Need to somehow work out how to temporarily copy all Preview open PDFs into a the source folder.

tell application "Preview"
	set gg to path of every document
end tell

The above unfortunately does not work. How do I get a list of open “Preview” files?

Right, I have the beginnings of a solution.

StefanK (thanks) has this in another post (

activate application "Preview"
tell application "System Events"
   tell process "Preview"
       tell (1st window whose value of attribute "AXMain" is true)
           set fileURL to value of attribute "AXDocument"
           set windowTitle to value of attribute "AXTitle"
       end tell
   end tell
end tell

This gives a result of

To make this fit with Michael’s script, how do I operate on this result to get a similar format to that when you get every item of a folder - ie:

If I can work this out, I can build a list which Michael’s python script can then work on.