5 Replies Latest reply on Jun 9, 2015 4:08 AM by ascotto

    how to address the backmost object in applescript?

    ascotto Level 1

      Hi all, I have an issue. Trying to upgrade a script I made -with some of you guys' help- that creates a tiny square (1x1px or so) in every master page, with 0.01 opacity, in order to export PDF with outlined text once transparency flattener preset is, actually, set. So, may I ask you if anyone has a better way to do the job -I know many printers use pdf-x and so on, but my boss wants outlined text for everything, so…-? Or, does anyone know how to address the backmost object(s) of the document? I thought to set their opacity to like 99.99, because sometimes if document size doesn't match the page one, my dear tiny clear squares drop over the page and become ineffective.


      Thanks all!

        • 1. Re: how to address the backmost object in applescript?
          AS Scripter Level 1

          -- I believe this  returns the frontmost text frame:


          tell application "Adobe InDesign CS6"

            tell document 1

            tell page 1

            set theframe to item 1 of (every text frame whose index is 1)

            end tell

            end tell

          end tell

          -- So, you should be able to loop all objects on the page and determine the object with

          -- the highest index number (ie, the backmost).

          • 2. Re: how to address the backmost object in applescript?
            ascotto Level 1

            Thanks, I'll let you know as soon as I try!

            • 3. Re: how to address the backmost object in applescript?
              Kevin Parrott Level 2

              have a look at lesson 20 in this link, it uses the term  "create outlines",  some of the code even goes into




              • 4. Re: how to address the backmost object in applescript?
                Laubender Adobe Community Professional & MVP

                @Kevin – the method createOutlines() (sorry, I'm an ExtendScript guy) is the wrong approach for this particular task.

                Underlined text will lose its underline, if a stroke is used in live text, the stroke's center will change, etc.pp.


                @ascotto – you are right: If you want "outlined" text in exported PDFs you have to use the transparency flattening process.


                But I would not do it with a tiny rectangle where opacity is set to 0.01, but with a big one on a seperate layer, a layer on top of all the other layers, a layer that is especially created for that task. The area of that rectangle will be the area of the page (maybe plus bleed). Its fill color will be "Paper", its stroke color will be set to "None" with opacity set to 0 (not set at all is a different thing).


                Tested with InDesign CS6 v8.1.0 on Mac OSX 10.7.5:

                ExtendScript (JavaScript) code:


                //Example for a special layer and a special rectangle
                //to force transparency flattener when properly set to convert text to outlines in PDF export
                //Rectangles covers every "regular" master page
                //IMPORTANT: It does *not* cover pages where master page "None" is applied !!
                //It will set the new layer as the top most layer
                //It will lock the new layer
                //If a layer named "Text2Path" is already there, it will do nothing.
                var myNewLayerName = "Text2Path";
                function createText2PathLayer(){
                    if(app.documents.length === 0){return};
                    var myDoc = app.documents[0];
                    var myActiveLayer = myDoc.activeLayer;
                    myDoc.activeLayer = myDoc.layers[0];
                    var myTextToPathLayer = myDoc.layers.add({name:myNewLayerName});
                    myDoc.activeLayer = myTextToPathLayer;
                    var myMasterPagesArray = myDoc.masterSpreads.everyItem().pages.everyItem().getElements();
                    for(var n=0;n<myMasterPagesArray.length;n++){
                    myTextToPathLayer.locked = true;
                    myDoc.activeLayer = myActiveLayer;


                Just test this with your transparency flattener preset.


                I used the following values:

                convertAllTextToOutlines = true

                gradientAndMeshResolution = 600

                lineArtAndTextResolution = 2400

                rasterVectorBalance = 100


                convertAllStrokesToOutlines = true



                • 5. Re: how to address the backmost object in applescript?
                  ascotto Level 1

                  Thanks! that works setting such a giant object -i didn't know how to do it in applescript, my square kept hanging to the top left corner- will solve the page resize issue, thanks a lot!