Hello Jarek & pixel.
Please see the snapshot attached.
My intention is to move the textframes which are outside the page bounds[0], back to the page.
when i group the pageitems and scale the text frames goes out the margins. and when running pixxel idea. the text frames goes upside and downside differently.
screen shot 1 before page resizing and scaling.

after page resizing and scaling.done.
the magenta textframe goes above and cyan text frame comes below. and cyan text frame is not toucing the margin as shown in screen shot 1.
I want to visual the same thing after resizing and scaling. just to move the textfrae again to the page.
my scribble ugly works is ;
var tf = app.activeDocument.textFrames.everyItem().getElements();
for(k=0; k<tf.length;k++) {
var oldPosition = [tf.geometricBounds[1].toFixed(3), tf.geometricBounds[0].toFixed(3)];
tf.label =
tf.geometricBounds[1].toFixed(3) + "|" + tf.geometricBounds[0].toFixed(3);
var g = app.activeDocument.pageItems.everyItem();
try {
var gr = app.activeDocument.groups.add(g);
} catch (e) {}
var bgr = gr.geometricBounds;
var hgr = bgr[2]-bgr[0];
// resize document
app.activeDocument.documentPreferences.pageWidth = 600;
app.activeDocument.documentPreferences.pageHeight = 1200;
var pm= gr.parent.marginPreferences;
with(pm)
{
var t = top;
var b = bottom;
}
app.activeDocument.pages.item(0).marginPreferences.top = 15;
// scale group to page height
var hn = app.activeDocument.pages.item(0).bounds[2] - app.activeDocument.pages.item(0).bounds[0];
var s = hn / hgr ;
tM = app.transformationMatrices.add({horizontalScaleFactor:s, verticalScaleFactor:s});
gr .transform(CoordinateSpaces.INNER_COORDINATES, AnchorPoint.TOP_CENTER_ANCHOR, tM );
app.select(gr);
//move the scaled item centrally:
htt =app.selection[0].geometricBounds[3]-app.selection[0].geometricBounds[1];
center = (app.activeDocument.pages.item(0).bounds[3]-htt)/2;
gr.move([center, app.activeDocument.pages.item(0).bounds[0]]);
app.activeDocument.pages.item(0).groups.everyItem().ungroup();
//send back the text frame to previous position, if they are outside the page left margin.
tf.move([tf.label.split("|")[0], tf.label.split("|")[1]]);
alert ("moved to old position");
}
Jarek please dont scold me for this ugly work... Im just a beginner...
Hi,
Try this for resizing last page of doc. Do it with other pages if needed.
var
targetPage = app.activeDocument.pages[-1];
changedPageSize = [210,180]; // width, height
currentPageSize = [
targetPage.bounds[3] - targetPage.bounds[1],
targetPage.bounds[2] - targetPage.bounds[0]
];
wFactor = changedPageSize[0]/currentPageSize[0];
hFactor = changedPageSize[1]/currentPageSize[1];
mGroup = targetPage.groups.add( targetPage.allPageItems );
targetPage.resize(
CoordinateSpaces.INNER_COORDINATES,
AnchorPoint.TOP_LEFT_ANCHOR,
ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY,
[wFactor, hFactor]);
mGroup.resize(
CoordinateSpaces.INNER_COORDINATES,
AnchorPoint.TOP_LEFT_ANCHOR,
ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY,
[wFactor, hFactor]);
Jarek