Skip to main content
Participant
November 26, 2008
Question

Trying to batch print to postscript and getting AppleScript Error!

  • November 26, 2008
  • 7 replies
  • 710 views
Here is the script as copied from Script Editor:

-- make a variable for the print settings to use:
set thPrintSettings to "Publishers PDF standard"
global thPrintSettings

-- initially, we'll allow for picking destinations at script start
set targetFolder to choose folder with prompt "Location for PDF files..."
global targetFolder

set varBasename to "CTB"

tell application "Adobe InDesign CS3"
-- Environment test: We want 1 book, no documents open:
try
get document 1
display dialog "Please run this script without any documents open (except one Book)" buttons "OK" default button 1
return
on error
-- we must be good to go, no documents open
end try
try
set thBook to book 1
on error
display dialog "Please open an InDesign Book to use this script" buttons "OK" default button 1
end try
if modified of thBook then
display dialog "This Book has been modified. Do you want to continue running the script?" buttons {"Cancel", "Yes"} default button 1
end if
tell thBook
set countOfThBook to (count of book contents)
set thContentsList to (full name of book contents) as list
end tell
-- return {countOfThBook, thContentsList}

set user interaction level of script preferences to never interact -- avoid any dialogs (for printing or saving)
set n to 0
repeat with j from 1 to countOfThBook -- loop through book's documents
set thDoc to item j of thContentsList
open thDoc
tell active document
repeat with c from 1 to (count of every ink)
tell ink c
set convert to process to true
end tell
end repeat
set myName to varBasename
repeat with i from 1 to count of pages -- loop through book's pages
set y to name of page i
set n to n + 1
tell print preferences
set page range to y --page range sets which page(s) to print
set active printer preset to thPrintSettings
set print file to alias ("" & targetFolder & myName & "_" & n & ".ps")
end tell
print --without print dialog
end repeat
close saving no
end tell
end repeat
end tell

Every time I try to run it I get the following error:

AppleScript Error
Adobe InDesign CS3 got an error: Invalid parameter.

Help!!!
This topic has been closed for replies.

7 replies

Inspiring
December 1, 2008
That suggests a problem with your printer preset.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
Participant
December 1, 2008
Thanks, that helped, but why is the dang thing printing out to the actual printer. I just want to postscript files to use in Distiller. Aack!
Inspiring
December 1, 2008
On 2/12/08 1:52 AM, "Jaime C. Starkey" <member@adobeforums.com> wrote:<br /><br />> I replaced the "set active printer preset" line to "set thPrintSettings to<br />> printer preset "CTB"<br /><br />No -- you should leave the "set active printer preset to thPrintSettings"<br />line as it was. The line you need to change is "set thPrintSettings to<br />"Publishers PDF standard"" -- that's where you need to insert "printer<br />preset".<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
Participant
December 1, 2008
Ok, I replaced the "set active printer preset" line to "set thPrintSettings to printer preset "CTB" -- "CTB" is the preset I created for this job.

The following error occurs..."Adobe InDesign CS3 got an error: Can't get printer preset "CTB" of print preferences of active document.
Inspiring
November 26, 2008
On 27/11/08 9:07 AM, "Jaime C. Starkey" <member@adobeforums.com> wrote:<br /><br />> "active printer preset"<br /><br />Try passing a reference to the preset, not just its name, by changing your<br />script:<br /><br />set thPrintSettings to printer preset "Publishers PDF standard"<br /><br />Also make sure you have such a preset defined (the names are<br />case-sensitive).<br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
Participant
November 26, 2008
"active printer preset"
Inspiring
November 26, 2008
On 27/11/08 5:22 AM, "Jaime C. Starkey" <member@adobeforums.com> wrote:<br /><br />> Every time I try to run it I get the following error:<br /><br />On which line of the script?<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>