Code: Select all
if (app.documents.length > 0)
{
//alert("more than 0");
var idoc = app.activeDocument;
var pageItemsCount = idoc.pageItems.length;
if (pageItemsCount>=1)
{
var margins = 3;
if (margins>=0)
{
var activeABindex = idoc.artboards.getActiveArtboardIndex();
var newAB = idoc.artboards[activeABindex];
var iartBounds = idoc.visibleBounds;
var ableft = iartBounds[0]-margins;
var abtop = iartBounds[1]+margins;
var abright = iartBounds[2]+margins;
var abbottom = iartBounds[3]-margins;
newAB.artboardRect = [ableft, abtop, abright, abbottom];
var myZoom = idoc.activeView.zoom;
idoc.activeView.zoom = myZoom+.01;
idoc.activeView.zoom = myZoom;
}
else
{
alert("nos vamos");
}
}
else
{
alert("there is no art in the active document");
}
}
else
{
alert ("there are no open documents");
}