• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Resolving Page Resize Discrepancies Due to Unit Conversion in InDesign Scripts

Participant ,
Sep 24, 2024 Sep 24, 2024

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>

TOPICS
Bug , How to , Scripting , SDK

Views

55

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 24, 2024 Sep 24, 2024

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
...

Votes

Translate

Translate
Community Expert ,
Sep 24, 2024 Sep 24, 2024

Copy link to clipboard

Copied

LATEST

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;
}

 

 

 

Screen Shot 3.png

 

 

Screen Shot 2.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines