Answered
Check the document for a margin or border
Good afternoon everyone!
Is there any way for a script to check if there is a 5mm white margin or border in the document?

If it's possible to share some script, I'll be very grateful.
Good afternoon everyone!
Is there any way for a script to check if there is a 5mm white margin or border in the document?

If it's possible to share some script, I'll be very grateful.
Based on the @Chuck Uebele tip, this script checks whether or not the document has borders of any size.
main();
function main(){
var startRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var doc = activeDocument;
doc.selection.selectAll();
notBorder();
var x1 = Number(doc.width);
var x2= Number(doc.selection.bounds[2]);
doc.selection.deselect();
if(x1 == x2){alert ("It has no border")}
else{alert ("Has border")}
app.preferences.rulerUnits = startRulerUnits;
}
function notBorder(){
var d1 = new ActionDescriptor();
var r = new ActionReference();
r.putProperty(app.charIDToTypeID("Chnl"), app.stringIDToTypeID("selection"));
d1.putReference(app.charIDToTypeID("null"), r);
var d2 = new ActionDescriptor();
d2.putUnitDouble(app.charIDToTypeID("Hrzn"), app.charIDToTypeID("#Pxl"), 0);
d2.putUnitDouble(app.charIDToTypeID("Vrtc"), app.charIDToTypeID("#Pxl"), 0);
d1.putObject(app.charIDToTypeID("T "), app.charIDToTypeID("Pnt "), d2);
executeAction(app.stringIDToTypeID("subtractFrom"), d1, DialogModes.NO);
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.