I’ve got a 2000 page InDesign document with 2000 different variances of a logo. Each page of the document has the “logo” and an identifier number in a separate text box. I’m looking to save each page of the document out as an EPS with a filename referencing the identifier number.
I’m very close but I’m getting an odd error of “Can’t make M into type PDF”.
Any help would be appreciated.
Current Script:
tell application “Finder”
activate
try
make new folder at (path to desktop) with properties {name:“eps_export_folder”}
end try
end tell
tell application “Adobe InDesign CS5.5”
set pageCount to count of pages of document 1
repeat with p from 1 to pageCount
set theName to text of text frame 1 of page p of document 1
set NewName to replace_chars(theName, ":", "") of me
set thePath to ((path to desktop) & "eps_export_folder:" & NewName) as string
save page p of document 1 in thePath as PDF
end repeat
end tell
on replace_chars(this_text, search_string, replacement_string)
set AppleScript’s text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript’s text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript’s text item delimiters to “”
return this_text
end replace_chars
Im not all that sure your that close. A question or two. You say you want *.eps files. then ask to save as PDF Which file format do you want.? I would go for *pdf *.eps is old and yuk. I’ve not even tried this but if it compiles it won’t work. You export files to another file format. If you go the route of *.pdf then you could just use a saved preset name ( this is what I use most ) if you want *.eps then you will need to set the options you require with the app’s preference suites. A little more info required.
Whoops…sorry about that. I was trying different formats while troubleshooting and accidentally left the PDF in there. I honestly fine with either EPS or PDF as I’m sure the end user will be taking these into Illustrator at some point.
Updated script (still getting same M error)
tell application “Finder”
activate
try
make new folder at (path to desktop) with properties {name:“pdf_export_folder”}
end try
end tell
tell application “Adobe InDesign CS5.5”
set pageCount to count of pages of document 1
repeat with p from 1 to pageCount
set theName to text of text frame 1 of page p of document 1
set NewName to replace_chars(theName, ":", "") of me
set thePath to ((path to desktop) & "pdf_export_folder:" & NewName) as string
set theProps to properties of PDF export preset "[Press Quality]"
export page p of document 1 in thePath as PDF
end repeat
end tell
on replace_chars(this_text, search_string, replacement_string)
set AppleScript’s text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript’s text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript’s text item delimiters to “”
return this_text
end replace_chars
So you are saying something like the following? With this change I’m now getting another error that is way over my head.
error “Can’t make every text of «class txtf» 1 of «class page» 1 of application "Adobe InDesign CS5.5" into type vector.” number -1700 from every text of «class txtf» 1 of «class page» 1 to vector
tell application "Finder"
activate
try
make new folder at (path to desktop) with properties {name:"pdf_export_folder"}
end try
end tell
tell application "Adobe InDesign CS5.5"
set pageCount to count of pages of document 1
repeat with p from 1 to pageCount
set theName to text of text frame 1 of page p of document 1
set NewName to replace_chars(theName, ":", "") of me
set thePath to ((path to desktop) & page p's text frame 1's text & ":" & "pdf_export_folder")
set theProps to properties of PDF export preset "[Press Quality]"
export page p of document 1 in thePath as PDF
end repeat
end tell
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
Sorry, that’s not what I intended, and it appears that I mistakenly transposed an item in my path example. The handler appears to serve no purpose, so I’ve removed it. It would be beneficial for you to download Adobe’s Applescript Scripting Guide for CS5, to see the proper syntax for the export command.
tell application "Adobe InDesign CS5.5"
set theProps to properties of PDF export preset "[Press Quality]"
tell document 1 to repeat with p from 1 to count pages
set thePath to ((path to desktop as text) & "pdf_export_folder:" & page p's text frame 1's text's item 1)
--insert Export command directed to page p
end repeat
end tell
Hi Marc and all, thank you so much for taking the time to help me.
I’m for sure still learning and have referenced the CS5.5 AppleScripting Guide but I’m still at a loss.
I’d appreciate anyones help with completing the export syntax. I get the syntax for exporting to PDF but including the page p variable is not sinking in.
Hello, again. There’s an example in the guide about exporting a range of pages to PDF. Do you see the application property page range of PDF export preferences? That’s typically set to “all pages”. Set it to your desired value (page p as text), then you export the document.
I just had a quick go at translating a script I use and this looks to do what you want for EPS export.
tell application "Adobe InDesign CS5"
if (count of documents) > 0 then
tell EPS export preferences
set bleed top to 0
set bleed bottom to 0
set bleed outside to 0
set bleed inside to 0
set data format to binary
set EPS color to CMYK
set EPS spreads to false
set font embedding to complete
set ignore spread overrides to true
set image data to all image data
set omit bitmaps to false
set omit EPS to false
set omit PDF to false
set OPI image replacement to false
set PostScript level to level 3
set preview to TIFF preview
end tell
set numb to count of pages of active document
repeat with i from 1 to numb
set str to contents of first text frame of page i of active document
set page range of EPS export preferences to (i as text)
set epsFile to (path to desktop as text) & str & ".eps"
export active document format EPS type to epsFile without showing options
end repeat
end if
end tell
PDF should be a little easier and a tad shorter but the same principle.
tell application "Adobe InDesign CS5"
if (count of documents) > 0 then
set pdfSet to PDF export preset "[Press Quality]"
set numb to count of pages of active document
repeat with i from 1 to numb
set str to contents of first text frame of page i of active document
set page range of PDF export preferences to (i as text)
set pdfFile to (path to desktop as text) & str & ".pdf"
export active document format PDF type to pdfFile using pdfSet without showing options
end repeat
end if
end tell
If these work in basic test ( a few pages don’t want 2k on the desktop ) then just adjust the paths to include your folder.