Printing multiple PDFs from Photoshop

I want to scriptically create 8.5x11 PDFs from 8.5x11 Scitex CTs using Photoshop CS2. No matter what I place in the save PDF options, the resulting PDF opens in Acrobat as 3.55"x4.33" (or close to that). This is the case whether I script it or save it manually. I couldn’t solve this, and Adobe’s Photoshop forum couldn’t come up with any solutions for this either although many suggestions were offered (at least one person had the exact same problem).

Anyhow, chasing this was a dead-end, but I did hit upon the fact that printing to printer “Adobe PDF 7.0” does indeed yield good PDFs. Excellent. Except…

I’m submitting multiple files to the script, and I have to deal with the Print and (since I’m printing PDFs) the Save to File dialogs. I actually want these to appear for the first file dropped so the customer can navigate to where he wants the files to go. But I want to avoid the dialogs for the other files in the group.

Trying to get System Events’ keystroke command and playing with delays was a nightmare since there are two dialogs to go through and it fails more often than it works. But I found that if I record an action that prints the PDFs and run the action from the AppleScript it works fine. Excellent. Except…

It always prints to a file by the name of the recorded file, thereby overwriting any earlier PDF. Is there a way to script this (or, OT for this forum, to edit the Photoshop action) so that successive “do action” calls print to the name of the currently open document or else some controlled filename that the script provides rather than the same name everytime?

Thanks very much for reading this far. I proofread this before submitting it and fell asleep about halfway through.

  • Dan

Impossible to help DanT without some portion of the script that you think fails.

My request was more along the lines of an approach to solve a problem rather than fixing broken code, but I’ll gladly lay out what I’ve done if someone thinks they can spot something. I figured the “saving” problem was a fait accompli so I removed all that code, but I wrote it below as I remember it, and in fact I’ve tested that part of the snippet and it does produce a 3.35x4.33 PDF as Acrobat sees it. I also have the “printing” code in the same script here.

I’ll simplify this greatly. I’ve got a list of lists of text strings, i.e., {{“abc”, “def”}, {“ghi”, “jkl”, “mno”}, {“pqr”, “stu”}}. The intended eventual output of this is three 8.5x11 PDF files, each a sheet of barcodes (“abc” and “def” on the first one, etc.) generated from CTs which in turn were created by a C program I wrote that is called from the script.

set pdfCount to 0
repeat with nameList in listOfLists
	set pdfCount to pdfCount + 1
	set nameOfCT to "TEST_" & pdfCount
	-- call C program to generate TEST_1.sct or TEST_2.sct or... from strings in nameList
	tell application "Adobe Photoshop CS2"
		set display dialogs to never
		open alias (pathToTheCT) as Scitex CT
		if pdfCount = 1 then -- do this on first pass only
			-- use Printer Setup Utility to verify "Adobe PDF 7.0" exists
			-- let's assume it does
			-- The following print statement will cause the Print window to open,
			-- where the user will select "Adobe PDF 7.0" as the printer, then click
			-- "Print", then the Save to File window opens, and he navigates to where
			-- he wants *all* of the PDFs to go, not just the first one.
			-- (An aside - I know that Printer Setup Utility can be used to set the current
			--  printer to "Adobe PDF 7.0" instead of requiring the user to select it but
			-- I'm having a problem with that also, which I'll live with for now.)
			print document "TEST_x.sct" -- or whatever this document's name is
			-- user has just manually responded to dialogs
			-- So far, first pass, everything is fine.
			-- Now we're on the 2nd, 3rd, 4th, ... pass.
			-- This is where I want to control the name of the output PDF that
			-- would normally be specified in the Save to File dialog but which
			-- is being by-passed by using the Photoshop action.
			do action "print_PDF" from "Default Action"
			-- just printed a perfectly fine PDF file, but it has the name of the
			-- previous one and thus overwrote it.
		end if
		-- Now the "save" attempt.
		set pdfname to "ANOTHER_TEST_X.pdf" -- distinct by pdfCount
		-- I've tried any number of options here.
		set pdfOptions to {PDF standard:none, preserve editing:false}
		save last document in (tHere & pdfname) as Photoshop PDF with options pdfOptions
		-- just saved the 8.5x11 CT as a 3.35x4.33 PDF, according to Acrobat.
	end tell
end repeat

Thanks very much.

  • Dan