Reply To: Script to take selected frame (artwork @ 10%), open new document with 100% scale

Home Page / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Script to take selected frame (artwork @ 10%), open new document with 100% scale / Reply To: Script to take selected frame (artwork @ 10%), open new document with 100% scale

#115754
Jeremy Howard
Participant

Hey there,

Try this script out, I think that it accomplishes what you are trying to accomplish. It scales an image dynamically to ensure that it gets scaled up to 100% in the new document (rather than scaling based on the static 1000%).

//////////////////////////////////////////////////////////////////////////////////////

//set selection as variable
var thisItem = app.selection[0];

//create new document
var myNewDocument = app.documents.add();

//duplicate selected item to new document
var myDuplicatedItem = thisItem.duplicate(myNewDocument.pages.item(-1));

//get image within the frame
var myLinkedItem = myDuplicatedItem.pageItems[0];

//find the horizontal and vertical scale integers
var myHscale = 100 / myLinkedItem.horizontalScale;
var myVscale = 100 / myLinkedItem.verticalScale;

//Scale the image around its center point
var myScaleMatrix = app.transformationMatrices.add();
myScaleMatrix = myScaleMatrix.scaleMatrix(myHscale, myVscale);
myLinkedItem.transform(CoordinateSpaces.PASTEBOARD_COORDINATES, AnchorPoint.centerAnchor, myScaleMatrix);

//fit frame to content
myDuplicatedItem.fit(FitOptions.frameToContent);

//////////////////////////////////////////////////////////////////////////////////////

This article was last modified on April 2, 2019

Comments (0)

Loading comments...