Copy link to clipboard
Copied
I'm trying to resize a page (dst) to the dimensions of a master page (src), this is what finally works:
function copyPageMetrics(src, dst) {
var bounds = src.bounds;
dst.resize(BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS,
AnchorPoint.TOP_LEFT_ANCHOR,
ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,
[bounds[3]*2.8346, bounds[2]*2.8346]);
}
I have the correct coordinates in bounds[3],bounds[2] (checked that with an alert()), but they didnt gave me the correct resize. To get the correct rresize, I had to multiply them with 2.8346, which is the factor of points in a mm.
Why? Why dont they use the same coordinate system? Is this always the case or do I have to get a page-specific translation-factor from somewhere?
<Title renamed by MOD>
Hi @Lordrhavin , By default the resize method’s width & height parameter is looking for points, so try setting your scripting preference units to points. This works for me:
var p = app.activeDocument.pages[1];
var am = p.appliedMaster.pages[0];
copyPageMetrics(am,p)
/**
* Resize page to master
* @ param source masterpage
* @ param page to resize
* @ return void
*
*/
function copyPageMetrics(s,d){
app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
var b = s.bounds
Copy link to clipboard
Copied
Hi @Lordrhavin , By default the resize method’s width & height parameter is looking for points, so try setting your scripting preference units to points. This works for me:
var p = app.activeDocument.pages[1];
var am = p.appliedMaster.pages[0];
copyPageMetrics(am,p)
/**
* Resize page to master
* @ param source masterpage
* @ param page to resize
* @ return void
*
*/
function copyPageMetrics(s,d){
app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
var b = s.bounds
d.resize (CoordinateSpaces.INNER_COORDINATES,AnchorPoint.TOP_LEFT_ANCHOR,ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,[b[3],b[2]])
app.scriptPreferences.measurementUnit = AutoEnum.AUTO_VALUE;
}