3 Replies Latest reply on May 18, 2010 3:03 AM by Marijan Tompa [tomaxxi]

    Document preferences returning wrong values

    Marijan Tompa [tomaxxi] Level 4



      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?



        • 1. Re: Document preferences returning wrong values
          [Jongware] Most Valuable Participant

          (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!

          • 2. Re: Document preferences returning wrong values
            Marijan Tompa [tomaxxi] Level 4



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



            • 3. Re: Document preferences returning wrong values
              Marijan Tompa [tomaxxi] Level 4



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