11 Replies Latest reply on Feb 17, 2015 12:12 PM by MKPETZ

    Find all transparent objects

    MKPETZ Level 1

      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!

        • 1. Re: Find all transparent objects
          Zantcor Level 1

          //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[i];

           

               if (myitem.visible == false);{

            

               alert ("Check transparency of selected item");

                         break;

           

          }//end if

          }//end for

          • 2. Re: Find all transparent objects
            Silly-V Adobe Community Professional

            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.

            • 3. Re: Find all transparent objects
              MKPETZ Level 1

              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.

              • 4. Re: Find all transparent objects
                Silly-V Adobe Community Professional

                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.

                • 5. Re: Find all transparent objects
                  MKPETZ Level 1

                  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
                  
                  • 6. Re: Find all transparent objects
                    Silly-V Adobe Community Professional

                    I'm pretty sure they have an applescript property like that, just see your library or the Applescript scripting guide.

                    http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/pdf/illustrator/scripting/cs6/Illus trator-Scripting-Reference-App…

                    • 7. Re: Find all transparent objects
                      MKPETZ Level 1

                      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.

                      • 8. Re: Find all transparent objects
                        Silly-V Adobe Community Professional

                        Yes, it does under raster items / properties.

                        • 9. Re: Find all transparent objects
                          MKPETZ Level 1

                          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}

                          • 10. Re: Find all transparent objects
                            Silly-V Adobe Community Professional

                            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.

                            • 11. Re: Find all transparent objects
                              MKPETZ Level 1

                              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