ok what about this :
//Given that myGraphic is a Graphic instance
var frame = myGraphic.parent;
frame.visibleBounds = frame.parentPage.bounds;
frame.fit ( FitOptions.PROPORTIONALLY ); //OR FILL_PROPORTIONALLY if you don’t mind cropped data
frame.fit ( FitOptions.CENTER_CONTENT);
?
Also see this :
var main = function() {
var doc = app.properties.activeDocument;
if ( !doc || app.selection.length!=1 ) return;
if ( ! ( app.selection[0] instanceof Rectangle ) ){
alert(“Please select some container”);
return;
}
var rect =app.selection[0];
if ( !rect.graphics.length ) {
alert(“The item needs a placed graphic”);
return;
}
var graphic = rect.graphics[0];
var page = rect.properties.parentPage;
if ( !page ) {
alert(“The item is not placed on a page”);
return;
}
var pageBounds = page.bounds;
var itemBounds = graphic.geometricBounds;
var itemHeight = Math.abs ( itemBounds[2]-itemBounds[0] );
var pageHeight = Math.abs ( pageBounds[2]-pageBounds[0] );
var pageWidth = Math.abs ( pageBounds[3]-pageBounds[1] );
var ratio = pageHeight/itemHeight;
const cs = CoordinateSpaces.INNER_COORDINATES,
ap = AnchorPoint.TOP_LEFT_ANCHOR,
rm = ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY;
graphic.resize ( cs, ap, rm, [ratio,ratio] );
itemBounds = graphic.geometricBounds;
var itemWidth = Math.abs ( itemBounds[3]-itemBounds[1] );
graphic.move([(pageBounds[1]-(Math.max (itemWidth, pageWidth)-Math.min(itemWidth, pageWidth))/2),0]);
rect.visibleBounds = page.bounds;
}
var u;
app.doScript ( “main()”,u,u,UndoModes.ENTIRE_SCRIPT, “The Script” );