Write a script for illustrator to fit artboard to selected items.
Hello,
I am searching for a sollution to write a script that scales the artboard in Illustrator.
What I need is a script that does as follow:
I make my artwork en select everything.
From this selection, the script wil adjust the size of the artboard.
The artboard will have the same size as the artwork but with an extra margin around it.
For example 10mm above, under, left and right from the artwork.
This is what I have so far, but it only shrinks in the width:
var docRef = app.activeDocument;
var index = docRef.artboards.getActiveArtboardIndex();
pdtRedim(index,docRef);
function pdtRedim(idx,doc){
var ab, rect0, rect;
ab = doc.artboards[idx];
rect0 = ab.artboardRect;
doc.fitArtboardToSelectedArt(idx);
rect = ab.artboardRect;
rect = [rect[0],rect0[1],rect[2],rect0[3]]
ab.artboardRect = rect;
}
Thank you in advance!
