Skip to main content
tomaxxi
Inspiring
May 18, 2010
Question

Document preferences returning wrong values

  • May 18, 2010
  • 2 replies
  • 416 views

Hello!

I have just one question...

Here is one piece of my script...

var doc = app.activeDocument;

var docPrefs = doc.documentPreferences;

var pageW = docPrefs.pageWidth;

var pageH = docPrefs.pageHeight;

var topM = margPrefs.top;

var leftM = margPrefs.left;

var rightM = margPrefs.right;

var bottomM = margPrefs.bottom;

and values I've got:

pageW = 209.99999999936

pageH = 296.999999999461

My document is pure A4, 210 x 297 mm

My question is, why I get decimal values?

tomaxxi

This topic has been closed for replies.

2 replies

tomaxxi
tomaxxiAuthor
Inspiring
May 18, 2010

Hey!

I just found here is the problem!

If you select predefined sizes, you get decimal values,

but if you enter size manualy, then all is ok.

So, It's bug in InDesign...

tomaxxi

Jongware
Community Expert
Community Expert
May 18, 2010

(1) InDesign does not store its measurements in the format you enter (or, in this case, taken from an internal list). Everything is converted to points internally. While this reclaculating is done with 15 decimals' worth of accuracy, some rounding will always occur.

(2) InDesign uses a "double" decimal storage format. Decimals cannot be lossless stored into this format -- compare it to expressing 1/3 in decimals ... The good news is, this storage format defines 52 bits for storing the decimals, and that's enough for 15 significant decimal digits. Not surprisingly, exactly the number of significant digits you got (perhaps Javascript is rigged not to return any more, as that would be meaningless).

(3) A4 is *not* exactly equal to 210 x 297 mm. A0 is defined to be exactly 1 square meter, with a length to width ratio of the square root of 0.5 (about 0.7071). Each next A-step down halves the size, so an A4 is defined to have a surface of exactly 1/16 m². Using the size ratio, that would come down to exactly  (sort of)  210.22 mm x  297.302 mm, with loads and loads of less significant decimals. However, that's the official definition!

tomaxxi
tomaxxiAuthor
Inspiring
May 18, 2010

Hey!

Thanks on your explanation, but...


Then why my margin values are correct if all is converted to points?

Second and third answer is I think not an issue here.

It's internal bug of InDesign.

I just tried to enter values for example: 298 x 211 mm,

and in script values are correct, without decimals.

So, where is the problem?

If you have some time, just try it...

Use standard A4 from page sizes...

tomaxxi