Copy link to clipboard
Copied
I am using an applescript to do anything I may miss before sending my files to the prepress department. Right now my script outlines all text (except item/batch numbers) and embeds any links. One other thing I really need to add is a simple alert if there are any transparent objects in the file. The file will be an illustrator PDF that may contain unflattened TIFF's and/or vector items with transparencies. Normally I check that a file has no transparencies using the flattener preview palette but I want a backup in case I miss/forget to check a file. I can't find any applescript or javascript code that has to do with checking for transparencies. Any scripting code using illustrator or image events to just notify about a transparency would be awesome. Thanks!
Yes, you would need to embed it first so that the tiff can be recognized as a raster item. If you don't want to keep embedded files in your document, just make a copy, embed and delete the copy after you've checked its properties.
Copy link to clipboard
Copied
//Check the below script, it should cycle through all of your object paths one at a time and check to see if they are visible, I may have missed //something. This may take a while if you have a large number of objects in your file.
//start script
var doc= app.activeDocument;
var L=docRef.pathItems.length;
for (i=0;i<L;i++)
{
myItem=doc.pathItems;
if (myitem.visible == false);{
alert ("Check transparency of selected item");
break;
}//end if
}//end for
Copy link to clipboard
Copied
Transparency in a file can take many forms, such as raster effects with transparency, blending modes, transparency within placed items, opacity less than 100, and objects with opacity masks on them. While it may be possible to check for many of the transparency attributes of a whole document's pageItems, one by one, it will not consider those transparent objects created by graphic styles/appearances and effects. To replicate the feature of the warning symbol in the PDF Save options dialog, I am not sure what can be done.
Copy link to clipboard
Copied
Thank you for the response. I would like to start with raster / placed images. Using applescript i got the properties of a tif with a transparent background. I do not see anything in the properties to indicate that the file is transparent. ( I do see blend mode and opacity which would help to check for page items. I've tried checking properties of individual page items before though, and it always crashes illustrator) Are you aware of code to check for transparencies on a placed image (when the transparency comes from the file, not a blend mode or opacity assigned to it in illustrator). Thanks again.
Copy link to clipboard
Copied
I am not sure about applescript, but in javascript while there is not such a property for a placedItem, there is a .transparent property for rasterItems . So there's probably such an applescript property too. Check out the type library?
--though I believe you will need to either embed the placed file first, or copy and then embed - check and then delete the copy of your placed file.
Copy link to clipboard
Copied
Awesome. If you have the script already, I can run a javascript in applescript. If not, I'll google for it..I don't know how to write javascript well. Just copy and paste and guess modify if i have to.
I wrote a quick applescript to check the opacity and blend mode of all page items and it is working on my test file so far.
tell application "Adobe Illustrator"
tell current document
set theitems to every page item
repeat with thetest in theitems
--set thetest to page item 1
set theprops to the opacity of thetest
if (theprops as string) is not equal to "100.0" then
tell application "Finder" to display dialog "You have a transparency"
end if
set theblend to the blend mode of thetest
if (theblend as string) is not equal to "normal" then
tell application "Finder" to display dialog "you have a transparency"
end if
end repeat
end tell
end tell
Copy link to clipboard
Copied
I'm pretty sure they have an applescript property like that, just see your library or the Applescript scripting guide.
Copy link to clipboard
Copied
It doesn't. All mentions of "transparen" have to do with either using the flattener preview to flatten a document, saving/exporting a file or creating/placing an image.
Copy link to clipboard
Copied
Yes, it does under raster items / properties.
Copy link to clipboard
Copied
I think that has to do with creating a raster image. When I get the properties of the tiff image in illustrator it refers to it as a placed item.
class:placed item
{file path:missing value, matrix:{class:matrix, mvalue_a:1.0, mvalue_b:0.0, mvalue_c:0.0, mvalue_d:-1.0, mvalue_tx:-7903.66666666667, mvalue_ty:8320.10666666666}, bounding box:{8074.0, 8357.56, 8308.0, 8060.44}, content variable:missing value, URL:"", note:"", layer:layer 1 of document 1 of application "Adobe Illustrator", locked:false, hidden:false, selected:true, position:{170.333333333334, 259.666666666665}, width:234.0, height:297.12, geometric bounds:{170.333333333334, 259.666666666665, 404.333333333334, -37.453333333335}, visible bounds:{170.333333333334, 259.666666666665, 404.333333333334, -37.453333333335}, control bounds:{170.333333333334, 259.666666666665, 404.333333333334, -37.453333333335}, name:"Test.tif", blend mode:normal, opacity:100.0, isolated:false, knockout:inherited, editable:true, sliced:false, visibility variable:missing value, pixel aligned:false, wrapped:false, wrap offset:missing value, wrap inside:missing value, container:layer 1 of document 1 of application "Adobe Illustrator", best type:reference, default type:reference, class:placed item, index:1}
Copy link to clipboard
Copied
Yes, you would need to embed it first so that the tiff can be recognized as a raster item. If you don't want to keep embedded files in your document, just make a copy, embed and delete the copy after you've checked its properties.
Copy link to clipboard
Copied
That's it! Thank you so much for working through this was me. Here is basic code to check through all raster items (embedded tif) and display an alert if it finds a transparent raster item.
tell application "Adobe Illustrator"
tell current document
set the_RasterItems to every raster item
repeat with each_RasterItem in the_RasterItems
set Test_Transparent to transparent of each_RasterItem
if (Test_Transparent as string) is "True" then
tell application "Finder" to display dialog "You have a Transparency!"
end if
end repeat
end tell
end tell
Find more inspiration, events, and resources on the new Adobe Community
Explore Now