Photoshop CS create PDF presentation from several scanned in docs

I’ve been messing with this for a week now on and off, and I can’t seem to get the syntax right. I can’t find an example anywhere on the web of where somebody has pulled off this script. The Applescript white paper for Photoshop says little to nothing about the “create pdf presentation” command. Can somebody help a noob to straighten this out?

I GUI scripted the scan import, which results in 2 to 10 pages “Untitled-1, Untitled-2, etc…” as active one-page documents. I need to use “create pdf presentation” to take these multiple documents and create a single multi-page pdf.

One hurdle is how to designate those open docs as the “list of alias”.

The script, once all put together, would allow me to scan multi page docs into a pdf on my desktop or a folder. Here’s what I have so far for the 2nd half, burning it to a pdf.

tell application "Adobe Photoshop CS"
	set myAlias to current documents
	create PDF presentation
	         from files myAlias
	         to file "Macintosh HD/Users/BradyPB17/Desktop/NameofPDF.pdf"
end tell

It won’t compile, after trying dozens of different approaches. The dictionary for Photoshop CS gives this general format:

create PDF presentation‚v : create a PDF presentation file
     create PDF presentation
          from files list of alias : list of input files to include in the output
          to file file specification : location of the output file
          [with options presentation options] : options for the PDF presentation
          → Unicode text : create a PDF presentation file

Any help would be greatly appreciated. This would be an awesome script for archiving documents.

Thanks up front

I’m trying to do a similar thing w/ Adobe Acrobat, but the software keeps crashing on me when I try to import more than one page. If anybody can offer advice on how this would work in Acrobat or Photoshop, that would be great.

I had better luck with quickly scanning all the pages into Photoshop CS than Acrobat. The only problem is that I’m one step from turning 8 documents into 1 8-pager. I know its possible, that’s why they included it in the script dictionary.

The “create PDF presentation” command setup is the only step I’m missing. I’m sure its a straight forward setup to someone who understands Applescripting Photoshop, but thats not me, yet.

Once I get this step worked out, I can use Filemaker to store the filepaths to these docs on the web server, index them, and create a smooth document storage solution. This is the only missing link if somebody is familiar with how this portion of the script should be set up.


I’ll post the progress I’ve made, although I still haven’t reached a solution, maybe someone can jump in.

Tried Working Papers X, which scans the multi-page document in as a single multi-page doc, rather than a whole list of single pages. However, it has almost no Applscript dictionary, and my ability to initiate the scan as well as direct the .pdf save and filename is nil.

Tinkered with using Preview to do it, but again, not Applescriptable, unless you ninja manipulate the UI using system events, which I have no experience in. Interesting read though, on the UI scriptable nature of OSX 10.3+

ReadIris could be an option, but I can’t seem to download the new demo to try it. Buggy, crappy website.

I still believe that Photoshop CS will do it, with good results on the file size, etc, I just haven’t figured out the finer points of their Applescript command “create PDF presentation”, and apparently nobody else on the web has either.

I’ve tried using an app called Extra Suites to simulate key-strokes, move the mouse, click the mouse to checkmark the “Add Open Files” box to identify all the open windows then save it. This works, but its a total kludge, if that window ever pops up in a different location, and it does, then my script doesn’t work. If I could even move that window in the script, to the exact same location every time, this approach would work regardless of it being a cheap hack.

But then again, they included the “create PDF presentation” in their dictionary to alleviate this mess. Please help!!!

Sorry I can’t really help out on the PS side of things, mcbrady. However, if you can get the window position, perhaps you could calculate the position of the required UI elements relative to the window itself. I recently tried something similar here (albeit with Safari’s Page Setup sheet).

It’s often possible to move a window using UI scripting. Here’s an example - again using Safari’s Page Setup sheet as the guinea pig:

tell application "Safari" to activate
tell application "System Events" to tell process "Safari"
	tell menu item "Page Setup." of menu "File" of ¬
		menu bar item "File" of menu bar 1
		if not enabled then error number -128
	end tell
	tell sheet 1 of window 1
		repeat until exists
			delay 0.1
		end repeat
		set position to {20, 140}
	end tell
end tell

Had a look at this and it thought it would have been an easy task. Unfortunatly I encountered the same problems and no matter how I tried to work the syntax it would either not compile or got errors when running.

Thanks for checking it out, isn’t it crazy how many different ways you can try to fudge to syntax, but never get it to work? There definitely is a way to do it, but Adobe wanted to keep it top secret apparently!

So I went to plan B, working out the GUI approach, and ran into some other issues of actually being able to “click” in the check boxes. Once the docs are scanned in, I run the following script, which compiles, and seems like it should work.

tell application "Adobe Photoshop CS"
end tell

tell application "System Events"
	tell process "Adobe Photoshop CS"
		click menu item "PDF Presentation..." of menu 1 of menu item "Automate" of menu 1 of menu bar item "File" of menu bar 1
		delay 1
		click checkbox "Add Open Files" of window "PDF Presentation"
		delay 1
		click button "Save" of window "PDF Presentation"
		delay 1
		set value of text field 1 of window "Save" to "MyFileName"
		delay 1
		click button "Save" of window "Save"
	end tell
end tell

I put the delays in to see if I could identify the problem. You can watch the “Add Open Files” box darken, as if it is being clicked, but it doesn’t get checkmarked off. Frustrating. I tried using the Extra Suites mouse click, right behind the “click checkbox” line, and it wouldn’t check it off either. Does anyone have any pointers on getting these GUI commands to punch through, and work?

So close I can smell it, but got stumped by the GUI too.

I tried to do the same for things like adding adjustment layers to files as this is not available through the scripting dictionary and got the same results. could only use return with defualt buttons no access to checkboxes etc.

Try this:

-- Create a temporary folder on the desktop that will contain the saved Photoshop documents (this assumes that no such folder already exists)
tell application "Finder" to set temporary_folder to (make new folder at desktop with properties {name:"TemporaryFolder"})

-- Save the Photoshop documents as ".psd" files in the temporary folder
-- Assuming the Photoshop documents are named "Untitled-1", "Untitled-2", ..., the new files will be named "Untitled-1.psd", "Untitled-2.psd", ...
tell application "Adobe Photoshop CS"
	set document_names to name of documents
	repeat with n from 1 to count documents
		set current document to document (item n of document_names)
		save current document in file ((temporary_folder as string) & (name of current document)) as Photoshop format appending lowercase extension
	end repeat
end tell

-- Create a list of aliases to the saved ".psd" files
tell application "Finder"
	set file_list to {}
	repeat with n from 1 to count files in temporary_folder
		set file_list to file_list & (file ("Untitled-" & (n as string) & ".psd") of temporary_folder as alias)
	end repeat
end tell

-- Create the ".pdf" file on the desktop (modify the create options to whatever you prefer)
tell application "Adobe Photoshop CS"
	create PDF presentation from files file_list to file "Macintosh HD:Users:BradyPB17:Desktop:NameofPDF.pdf" with options {encoding:JPEG, JPEG quality:10, presentation:false}
end tell

-- Trash the temporary folder
tell application "Finder" to move temporary_folder to trash