Answered
Need help unable to progress
_SaftyMargin();
function _SaftyMargin(){
//_reportMatch.push("Check_safty_margin");
var myDoc = app.activeDocument;
var myPages = myDoc.pages;
var marginValue = 12.7;
convertToMM();
for(var p=0;p<myPages.length;p++){
var BoundsTop = myPages[p].bounds[0].toFixed(2);
var BoundsLeft = myPages[p].bounds[1].toFixed(2);
var BoundsBottom = myPages[p].bounds[2].toFixed(2);
var BoundsRight = myPages[p].bounds[3].toFixed(2);
var myPagesItem = myPages[p].allPageItems;
for(var s=0;s<myPagesItem.length;s++){
if (myPagesItem[s].itemLayer.visible == true && myPagesItem[s].visible == true) {
if(myPagesItem[s].constructor.name != "PDF"
&& myPagesItem[s].constructor.name != "Image" && myPagesItem[s].constructor.name != "EPS"){
var geo = myPagesItem[s].geometricBounds;
var objTop = geo[0].toFixed(2);
var objLeft = geo[1].toFixed(2);
var objBottom = geo[2].toFixed(2);
var objRight = geo[3].toFixed(2); //0,0,215.9,274.4
alert(objTop + ">" + BoundsTop + "&&" + objLeft + ">" + BoundsLeft + "&&" + objBottom + "<" + BoundsBottom + "&&" + objRight + "<" + BoundsRight);
if(objTop > BoundsTop && objLeft > BoundsLeft && objBottom < BoundsBottom && objRight < BoundsRight){
if(objTop < BoundsTop+marginValue || objLeft < BoundsLeft+marginValue || objBottom > BoundsBottom-marginValue || objRight > BoundsRight-marginValue){
alert(myPages[p].name);
}
}
else if(objTop == BoundsTop || objLeft == BoundsLeft || objBottom == BoundsBottom || objRight == BoundsRight){
alert(myPages[p].name);
}
}
}
}
}
}
function convertToMM(){
app.activeDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;
app.activeDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
app.activeDocument.zeroPoint = [0,0];
}
For this screenshot case the above script is not working I even checked with alert that all case in the IF loop is getting true.
To my knowledge the above script should work but it is not working. Kindly help me to progress further.
Thanks
