4 Replies Latest reply on Jul 23, 2013 7:06 AM by athkini

    Alert Frames equal to doc. size


      HI forum,


      Baby to the javascripting scripting.


      I have a script, which will alert if the Last frame size [RECTANGLE] is equal to the document width and height..


      I just really need a help from you, to check, IF ANY OF THE FRAME, IS EQUAL TO DOCUMENT WIDTH AND HEIGHT.  [not just the last item] and ALERT..



      var doc = app.documents[0];

      rec = doc.rectangles.lastItem();


      rectHeight = Math.round(rec.geometricBounds[ 2] - rec.geometricBounds[0]);

      rectWidth = Math.round(rec.geometricBounds[ 3] - rec.geometricBounds[1]);



          if (rectHeight == Math.round(app.activeDocument.documentPreferences.pageHeight) &&



              rec.itemLayer = doc.layers.itemByName(layerName);






        • 1. Re: Alert Frames equal to doc. size
          athkini Level 1

          Hi Forum,


          Here im'm trying to compare the height of the Links like this.. could any body help on this please...please..


          if !== is applied, the alert if produced.. if == just skips..


          var g = app.activeDocument.allGraphics;
          for (var i = 0; i < g.length; i++){
              var fileName = File(g[i].itemLink.filePath).name;
              var scaleVert = g[i].itemLink.parent;
              var scaleHor = g[i].itemLink;
                    // app.select(g[i].itemLink.parent.absoluteVerticalScale);

          var scalW = scaleVert.geometricBounds[2]-scaleHor.parent.geometricBounds[0];

          if( scalW.geometricBounds==Math.round(app.activeDocument.documentPreferences.pageHeight)){


                  alert ("one of the link height is equal to docu height")}}
          • 2. Re: Alert Frames equal to doc. size
            Lucky Siva



            Please check if this is you need:



            var doc=app.activeDocument;

            var pagewidth=parseFloat(doc.documentPreferences.pageWidth.toFixed(3));

            var pageheight=parseFloat(doc.documentPreferences.pageHeight.toFixed(3));

            //~ $.writeln(pagewidth);

            //~ $.writeln(pageheight);



            for(var i=0; i<doc.pageItems.length; i++){

                var tfw=parseFloat(doc.pageItems[i].geometricBounds[3].toFixed(3))-parseFloat(doc.pageItems[i ].geometricBounds[1].toFixed(3));

                var tfh=parseFloat(doc.pageItems[i].geometricBounds[2].toFixed(3))-parseFloat(doc.pageItems[i ].geometricBounds[0].toFixed(3));

            //~     $.writeln(tfw);

            //~     $.writeln(tfh);

                if(tfw==pagewidth && tfh==pageheight){

                    $.writeln("A Pageitem is same as document width and heigth in the page " + doc.pageItems[i].parentPage.name);



            • 3. Re: Alert Frames equal to doc. size
              Jump_Over Level 5



              modify this line:

              if( Math.round(scalW) == Math.round(app.activeDocument.documentPreferences.pageHeight) ) {



              • 4. Re: Alert Frames equal to doc. size
                athkini Level 1

                Hellow Jump_Over!


                You are correct and thanks for the tweakings.


                but i do want a have small tweaks also, I do want to alert if the graphics scaling is equal to page width or height (as I got answer from you).


                Also, i do want to distinguish alert for the graphics width with stroke applied  and rectangle width (which will not have any graphics place inside). A bare rectangle frame.


                the above script, alert for both, if matches with the document width or height..


                thanks so much.J..