Here’s my pre-press script that automates the things I used to do by hand. It’s specific to our purposes, but feel free to use any parts that are useful to you.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--WHAT THIS SCRIPT DOES:
--It adds an object style with the drop shadow
--If a text frame has overflowing text, it fits the text frame to the text.
--It brings every text frame that has a transparent background to the front
--It fits graphic frames to the content IF the square inches of the image is not more than 0.25" more than the frame. (So, it will fit the frame to images that are slighly cut off and leave cropped images that are way cut off alone).
--It locks every group and every image that is in the document twice
--Next, it duplicates every unlocked image that is in the 1_4c images folder, sends the duplicate back one step, changes the duplicate's height so it is only 0.08" tall, applies the drop shadow object style to the duplicate and groups the duplicate with the original
--Then, it unlocks everything
--It moves every logo to the front, so that the logos will not be fuzzy due to transparency flattening of images in front of them
--Last, it changes anything in Registration to Black. (*This does not work if the object in registration is part of a group. I decided I would rather preview the color separations than ungroup a bunch of objects someone grouped)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
on open of droppedFiles
with timeout of 900 seconds -->The script will try for 15 minutes before timing out.
---------------------------------------------------------------
--GETTING RID OF ANNOYING POPUP BOXES
tell application "Adobe InDesign CC 2014"
set user interaction level of script preferences to never interact -->Prevents InDesign from popping up warnings that interrupt the script. Instead, I added code that puts documents with problems in a separate folder.
tell view preferences
set horizontal measurement units to inches
set vertical measurement units to inches
end tell
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
--BEGINNING REPEAT LOOP AND OPENING FILE
repeat with afile in droppedFiles
open afile
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
--UNLOCKING PAGE ITEMS JUST IN CASE SOMETHING WAS LOCKED
tell document 1
set locked of page items to false
-----------------------------------------------------------------------------------------
---------------------------------------------------------------
--CREATING A DROP SHADOW OBJECT STYLE TO BE APPLIED LATER ON
try
set dropShadowStyle to object style "Drop Shadow"
on error
--The character style did not exist, so create it.
set dropShadowStyle to make object style with properties {name:"Drop Shadow", enable drop shadow:true, enable transparency:true, enable stroke:false}
tell dropShadowStyle
--Applying the drop shadow to the text
tell transparency settings
set properties of drop shadow settings to {mode:drop, use global light:true, opacity:40, spread:10.0, blend mode:multiply, noise:1.0, x offset:".02", y offset:".02", distance:".04", size:".04", effect color:"Black"}
end tell
end tell
end try
---------------------------------------------------------------
---------------------------------------------------------------
--FITTING TEXT FRAMES TO THE CONTENT IF THERE IS AN OVERFLOW
--THIS WAY WE DON'T RISK HAVING CUT OFF TEXT IN AN AD
--Looking through every text frame and fitting the frame to content if there is overset text
set everyTextFrame to every text frame
repeat with textFrame in everyTextFrame
if overflows of textFrame then
fit textFrame given frame to content
end if
--Looking through every anchored text frame within each text frame
--fitting the anchored text frame to content if there is overset text
set anchoredTextFrames to all page items of textFrame
repeat with i from 1 to number of anchoredTextFrames
set anchoredTextFrame to item i of anchoredTextFrames
if overflows of anchoredTextFrame then
fit anchoredTextFrame given frame to content
end if
end repeat
end repeat
---------------------------------------------------------------
-----------------------------------------------------------------------------------------
--SELECTIVELY MOVING TEXT BOXES TO THE FRONT
--BECAUSE THE TEXT HAS LINES THROUGH IT IF IS NOT BROUGHT TO THE FRONT
--Bringing each text frame to the front IF the fill color of that text frame is "None"
--It could mess up the layout if text boxes with a background color were brought to the front, so I added a condition to make sure that doesn't happen.
set theTextFrames to (every text frame whose name of fill color is "None")
bring to front theTextFrames
-----------------------------------------------------------------------------------------
------------------------------------------------------------------------
--BUILDING A LIST OF THE GRAPHICS THAT ARE IN THE DOCUMENT MORE THAN ONCE
--This section of code is referenced later in the adding a drop shadow section
--Looping through every graphic to build a list that contains the name of every link
set originalList to {}
set allGraphics to all graphics
repeat with i from 1 to count allGraphics
set aGraphic to item i of allGraphics
set aLink to item link of aGraphic
set aLinkName to name of aLink as string
set originalList to originalList & aLinkName
end repeat
--returns {AG12345.tif, AG54321.tif, AG54321.tif}
--------------------------
--Building two lists of every link that has at least 2 copies in the document
set list1 to {}
--display dialog aLinkName & "-" & matchCount
repeat with x from 1 to count of items of originalList
set n to item x of originalList
--if n is in list2 and n is not in doubleImageList then set end of doubleImageList to n
set matchCount to my count_matches(originalList, n)
if matchCount is greater than 1 then
set list1 to list1 & n
end if
end repeat
--returns {AG54321.tif, AG54321.tif}
set list2 to {}
repeat with x from 1 to count of items of originalList
set n to item x of originalList
set matchCount to my count_matches(originalList, n)
if matchCount is greater than 1 then
set list2 to list2 & n
end if
end repeat
--returns {AG54321.tif, AG54321.tif}
--------------------------
--Building final list which only contains the name of duplicate images once
set doubleImageList to {}
repeat with x from 1 to count of items of list1
set n to item x of list1
if n is in list2 and n is not in doubleImageList then set end of doubleImageList to n
end repeat
--returns {AG54321.tif}
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
set theGraphics to all graphics
repeat with n from 1 to count theGraphics
--Getting information about each image
set theGraphic to item n of theGraphics
set theLink to item link of theGraphic
set theImage to parent of theLink
set theFrame to parent of theImage
set linkPath to file path of theLink as string
set theLinkName to name of theLink as string
set frameGB to geometric bounds of theFrame
set imageGB to geometric bounds of theImage
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
--FITTING GRAPHIC FRAMES TO CONTENT IF THE SQUARE INCHES OF THE IMAGE IS LESS THAN THE SQUARE IMAGE OF THE (FRAME + 0.33")
--This allows the script to fit frames to images that are slightly cut off, but it won't uncrop images that are intentionally cut off by a lot
--Getting the height and width of each frame
set frameWidth to (item 4 of frameGB) - (item 2 of frameGB)
set frameHeight to (item 3 of frameGB) - (item 1 of frameGB)
set frameSquareInches to frameWidth * frameHeight
--Getting the height and width of each image
set imageWidth to (item 4 of imageGB) - (item 2 of imageGB)
set imageHeight to (item 3 of imageGB) - (item 1 of imageGB)
set imageSquareInches to imageWidth * imageHeight
--Adding a quarter inch to the square inches of the frame
set frameSquareInchesOversize to frameSquareInches + 0.25
--Fitting frame to content only if the frame is not cutting off a lot of the image
--Sometimes, we have images with multiple products and each product will get cropped into it's own separate box.
--We don't want frames to fit to content in that instance
if imageSquareInches is less than frameSquareInchesOversize then
fit theFrame given frame to content
end if
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
--ADDING A DROP SHADOW TO ALL PRODUCT IMAGES THAT DON'T ALREADY HAVE A DROP SHADOW
--Adding the drop shadow only to images that are product images (logos and stock photos will not get a drop shadow)
if linkPath contains "1_4c IMAGES" then --Choosing everything that has 1_4c IMAGES in the path of it's link (basically all the product images)
--Locking all the groups in the document
--If we don't lock the groups, we will get extra drop shadows
set theGroups to every group
repeat with theGroup in theGroups
tell theGroup
set locked to true
end tell
end repeat
--Locking every frame that already has a drop shadow
--We know it probably has a drop shadow because it is in the document twice
if doubleImageList contains theLinkName then
if locked of theFrame is false then
set locked of theFrame to true
end if
end if
--Getting coordinates of each side of the frame to be used in creating the duplicated frame for the drop shadow
--Geometric bounds is {top of frame, left side of frame, bottom of frame, right side of frame} or {item 1, item 2, item 3, item 4}
tell theFrame
set topOfFrame to item 1 of geometric bounds
set leftSideOfFrame to item 2 of geometric bounds
set bottomOfFrame to item 3 of geometric bounds
set rightSideOfFrame to item 4 of geometric bounds
set frameHeight to bottomOfFrame - topOfFrame as number --Getting height to be used later on in removing short frames with drop shadows
set offsetTopOfFrame to bottomOfFrame - 0.08 --This is the coordinate for the top of the duplicated frame that contains the drop shadow. We want it to be only slightly above the bottom of the frame.
end tell
--Duplicating the product image frame and resizing so it is only .05" tall instead of the full height of the image
--We just want a short little box at the bottom of the image for the drop shadow
if locked of theFrame is false then
set duplicateFrame to duplicate theFrame
set geometric bounds of duplicateFrame to {offsetTopOfFrame, leftSideOfFrame, bottomOfFrame, rightSideOfFrame} --resizing the frame so it is only 0.08" tall
--Sending the image frame with the drop shadow back one step
send backward duplicateFrame
--Applying the drop shadow to the duplicated image frame
tell duplicateFrame
apply object style using dropShadowStyle
end tell
--Grouping the image with the drop shadow
set mySelection to {theFrame, duplicateFrame}
try
make new group at parent of item 1 of mySelection with properties {group items:mySelection}
end try
end if
end if
--Unlocking all images
set locked of page items to false
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
--SELECTIVELY MOVING LOGOS TO THE FRONT
--BECAUSE THE LOGOS ARE FUZZY IF THEY ARE NOT BROUGHT TO THE FRONT
--Getting the height and width of each image box and then calculating the square inches
--ImageGB (the geometric bounds of the image) are {top side, left side, bottom side, right side}
set imageHeight to (item 3 of imageGB) - (item 1 of imageGB) --Item 3 is the bottom of the image and item 1 is the top, so the coordinates of the bottom of the image minus the coordinates of the top of the image equals the image height
set imageWidth to (item 4 of imageGB) - (item 2 of imageGB) --Item 4 is the right side of the image and item 2 is the left side, so the coordinates of the left side minus the coordinates of the right side equals the image width
set imageSquareInches to imageHeight * imageWidth as number
--Bringing the image to the front under certain conditions
--Bringing the ".tiff" images or boxes that contain a color to the front would mess up the layout, so I had to add if statements to make sure that doesn't happen.
if imageSquareInches is less than 1 and linkPath contains "LOGOS" then --Bringing every image that is less than 1 square inch and in the LOGOS folder to the front
bring to front theFrame
else if imageSquareInches is less than 1 and linkName contains ".eps" then --Bringing the image to the front if it is less than 1 square inch in size and if it is an eps file
bring to front theFrame
else if imageSquareInches is less than 1 and linkName contains ".ai" then --Bringing the image to the front if it is less than 1 square inch in size and if it is an ai file
bring to front theFrame
end if
end repeat
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
--PART 8 - DELETING ANY UNUSED SWATCHES THAT ARE NOT CYAN, MAGENTA, BLACK, PAPER, RICH BLACK, REGISTRATION OR NONE
--Setting a list of swatch names that will be kept even if unused
set swatchesToKeep to {"Cyan", "Black", "Rich Black", "Magenta", "Yellow", "Paper", "None", "C=100 M=0 Y=0 K=0", "C=0 M=100 Y=0 K=0", "C=0 M=0 Y=100 K=0", "C=0 M=0 Y=0 K=100", "C=30 M=30 Y=30 K=100", "Registration"}
--Setting a swatch for registration
set registrationSwatch to {"Registration"}
--Getting every swatch in the document
set documentSwatches to every swatch
--Getting all unused swatches in the document
set unusedSwatches to unused swatches
repeat with documentSwatch in documentSwatches
--Finding the names of unused swatches and deleting that name IF the swatch is not in the list of swatches to keep (see above variable swatchesToKeep)
if documentSwatch is in unusedSwatches then
set unusedSwatchName to name of documentSwatch as string
if swatchesToKeep does not contain unusedSwatchName then
delete documentSwatch
end if
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
--CHANGING ANYTHING IN REGISTRATION TO BLACK
--Checking to see if the Registration swatch is used and changing everything that is in Registration to Black
else if documentSwatch is not in unusedSwatches and registrationSwatch contains name of documentSwatch then
set documentBoxes to (every item of all page items whose class is text frame)
set graphicBoxes to (every item of all page items whose class is rectangle)
--Changing registration fills and strokes on graphic boxes to black
repeat with graphicBox in graphicBoxes
set graphicFillColor to name of fill color of graphicBox
set graphicStrokeColor to name of stroke color of graphicBox
if graphicFillColor contains "Registration" then
set fill color of graphicBox to "Black"
end if
if graphicStrokeColor contains "Registration" then
set stroke color of graphicBox to "Black"
end if
end repeat
--Changing registration fills and strokes on text frames to black
repeat with documentBox in documentBoxes
tell documentBox
set fillColor to name of fill color
set strokeColor to name of stroke color
if fillColor contains "Registration" then
set fill color to "Black"
end if
if strokeColor contains "Registration" then
set stroke color to "Black"
end if
end tell
end repeat
end if
end repeat
--Changing all registration text to black
set registrationSwatch to swatch "Registration"
tell (stories's characters whose fill color's name is "Registration") to if not it is {} then set fill color to "Black"
tell (stories's characters whose stroke color's name is "Registration") to if not it is {} then set stroke color to "Black"
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
--SAVING & CLOSING THE DOCUMENTS
close saving yes
---------------------------------------------------------------
end tell --end of tell document 1 block
end repeat --end of first repeat loop
end tell --end of tell InDesign block
end timeout
end open
--------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------
--HANDLER THAT COUNTS THE NUMBER OF TIMES AN ITEM IS IN THE LIST
on count_matches(this_list, this_item)
set the match_counter to 0
repeat with i from 1 to the count of this_list
if item i of this_list is this_item then ¬
set the match_counter to the match_counter + 1
end repeat
return the match_counter
end count_matches