this post is a response to a question from Tom :
I am working towards a compilation of scripts to take customer supplied Indd documents – Drop them on applet or automator – Print 1 laser / create 3 PDF files (different settings) / email the low res proof to CSR. … What I picture in my head is getting the email PDF proof script running the way I want – Put it into automator as part of a larger workflow. Then get the other elements as scripts – put those into the same workflow – ??
two things to note straight up — you don’t need separate scripts and you don’t need automator. but this is a great little example because all we need to do is pull together a bunch of script snippets already scattered around this site. as you read through you’ll see highlighted bits that link back to posts with more details.
let’s go … first things first — we want this to be a droplet (so you can drag and drop files onto the app for processing) so the whole script will be wrapped in an on open handler. and you’ll need to wrap it in a repeat loop so it can handle more than one dropped file at a time. and it would be a good idea to alert the user when the script has finished doing its thing. so the initial bits will look something like this :
on open mgItems repeat with mgThisItem in mgItems -- rest of script here end repeat display dialog "some kind of confirmation message here" end open
then we need InDesign to open and process each file. but we should put this in a try block to ensure the script doesn’t crash if a different file type is dropped on it inadvertently :
on open mgItems repeat with mgThisItem in mgItems tell application id "com.adobe.InDesign" try open mgThisItem tell active document -- do printing and pdf stuff in InDesign end tell close active document on error -- decide what kind of error handling you want to include if the file won't open end try end tell -- rest of script for email processing here end repeat display dialog "some kind of confirmation message here" end open
the observant will notice that the tell application command is different from previous scripts on this site. this is the way to address any version of InDesign — but be aware that other parts of this script may have terms or syntax that may need to be adjusted for your particular version of InDesign.
ok — next comes the printing bit. if you’re using only one print preset for this workflow you’d use a simple line :
print using "name_of_print_preset" without print dialog
but if you need to change the print preset based on the file specs you’d need something more complex like in InDesign scripting : lesson 24.
exporting pdfs is covered in lessons 08, 09, 10, 11, and 12 and cover a few different ways to approach the problem. three basic things need to be determined : the export preset to be used, the name of the pdf and the location to save it to.
the simplest version of this part of the workflow might look like this (but depends on Tom’s specific needs) :
set mgDocName to name of active document set text item delimiters of AppleScript to " " set mgShortName to text item 1 of mgDocName set text item delimiters of AppleScript to "" set mgHRFilePath to "path:to:highres:folder:" & mgShortName & "_HR.pdf" as string set properties of PDF export preferences to properties of PDF export preset "HighRes" tell active document export format PDF type to mgHRFilePath without showing options end tell set mgHRDigitalFilePath to "path:to:highresdigital:folder:" & mgShortName & "_HRD.pdf" as string set properties of PDF export preferences to properties of PDF export preset "HighResDigital" tell active document export format PDF type to mgHRDigitalFilePath without showing options end tell set mgProofFilePath to "path:to:proof:folder:" & mgShortName & "_proof.pdf" as string set properties of PDF export preferences to properties of PDF export preset "Proof" tell active document export format PDF type to mgProofFilePath without showing options end tell
that’s it for the InDesign bits. now to email that third pdf. first get a reference to the file, then create the message — Tom’s using Entourage (thanks to Ben Waldie at MacTech for the Entourage code) :
tell application "Finder" set mgFile to mgProofFilePath as alias end tell set mgSubject to "proof of job " & mgShortName as string tell application "Microsoft Entourage" set theRecipients to {{address:{display name:"CSR Name", address:"CSR@tomsplace.com"}, recipient type:to recipient}} set theMessage to make new outgoing message with properties {recipient:theRecipients, subject:"mgSubject", content:"here's your proof dude", attachments:mgFile} send theMessage end tell
again, this is pretty much the simplest form this part of the workflow could take. Tom will need to expand it to encompass his particular requirements.
the final basic structure could look something like this :
on open mgItems repeat with mgThisItem in mgItems tell application id "com.adobe.InDesign" try open mgThisItem tell active document print using "name_of_print_preset" without print dialog end tell set mgDocName to name of active document set text item delimiters of AppleScript to " " set mgShortName to text item 1 of mgDocName set text item delimiters of AppleScript to "" set mgHRFilePath to "path:to:highres:folder:" & mgShortName & "_HR.pdf" as string set properties of PDF export preferences to properties of PDF export preset "HighRes" tell active document export format PDF type to mgHRFilePath without showing options end tell set mgHRDigitalFilePath to "path:to:highresdigital:folder:" & mgShortName & "_HRD.pdf" as string set properties of PDF export preferences to properties of PDF export preset "HighResDigital" tell active document export format PDF type to mgHRDigitalFilePath without showing options end tell set mgProofFilePath to "path:to:proof:folder:" & mgShortName & "_proof.pdf" as string set properties of PDF export preferences to properties of PDF export preset "Proof" tell active document export format PDF type to mgProofFilePath without showing options end tell close active document on error -- decide what kind of error handling you want to include if the file won't open end try end tell tell application "Finder" set mgFile to mgProofFilePath as alias end tell set mgSubject to "proof of job " & mgShortName as string tell application "Microsoft Entourage" set theRecipients to {{address:{display name:"CSR Name", address:"CSR@tomsplace.com"}, recipient type:to recipient}} set theMessage to make new outgoing message with properties {recipient:theRecipients, subject:"mgSubject", content:"here's your proof dude", attachments:mgFile} send theMessage end tell end repeat display dialog "some kind of confirmation message here" end open
of course, this isn’t a definitive solution — it’s simply a demonstration of one possible approach to the problem.
once you’re done compiling the perfect script, save it as an app and drag it onto your sidebar so it’s easily accessible — then start dropping those indd files.