2 Replies Latest reply on Sep 3, 2014 2:21 PM by Mrtreebis

    Script to display InDesign Page Size instead of Document Setup size

    Mrtreebis

      Hello, I was very kindly helped out with the below script (using a text variable) which displays the size of the current page within an InDesign document.

      The result it gives is based on the Document Setup, and I was wondering if it was possible to amend it to base the result on the Page Size instead (as you can now change the page size independently of the Document Setup within InDesign using the Page Tool). I don't know anything about scripting by the way!

      Many thanks in advance for any help.

       

       

      var doc = app.activeDocument; 

      doc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.millimeters; 

      doc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.millimeters; 

      var w = doc.documentPreferences.pageWidth, 

          h = doc.documentPreferences.pageHeight, 

          pagesize = app.activeDocument.textVariables.itemByName("PageSize"); 

      pagesize.variableOptions.contents = h + " mm X " + w + " mm"; 

        • 1. Re: Script to display InDesign Page Size instead of Document Setup size
          Chinnadk Level 4

          Try this,

           

          var doc = app.activeDocument;
          doc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.millimeters;
          doc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.millimeters;
          for(var i =0;i<doc.pages.length;i++)
          {
                  alert("Page Width : " +  doc.pages[i].bounds[3] + "\rPage Height : " + doc.pages[i].bounds[2] )
              }
          

           

          Regards,

          Chinna

          • 2. Re: Script to display InDesign Page Size instead of Document Setup size
            Mrtreebis Level 1

            Hi Chinna, thank you for this - this is great - apologies if i didn't make it clear but this displays the info as an alert, and i needed it to appear in the "PageSize" text variable field as per the text in my post. However i think I've managed to work it out (pasted below if you're interested), and it works a treat now, so thank you ever so much for all your help.

             

            - - - - - - - - - - - - -

             

             

            var doc = app.activeDocument; 

            doc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.millimeters; 

            doc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.millimeters; 

            for(var i =0;i<doc.pages.length;i++)

            {

                pagesize = app.activeDocument.textVariables.itemByName("PageSize"); 

            pagesize.variableOptions.contents = doc.pages[i].bounds[2] + "mm x " + doc.pages[i].bounds[3] + "mm"

            }

             

             

            - - - - - - - - - - - - -