3 Replies Latest reply on Mar 3, 2014 7:26 AM by DavidFdezGlez

    Setting MasterSpread to single-sided page and Page Number

    DavidFdezGlez

      Hello everyone,

       

      I'm trying to set the Master Spread to single-sided page, and also the page number.

       

       

       // height, width, pageNumber are well defined 
       var document = app.documents.add();
         
          with (document.viewPreferences) {
              horizontalMeasurementUnits = MeasurementUnits.POINTS; 
              verticalMeasurementUnits = MeasurementUnits.POINTS;
              
          }
         
          with (document.documentPreferences){
              pageHeight = height;
              pageWidth = width;
              facingPages = false;
              pagesPerDocument = pageNumber;
          }
         
                                      
        while(document.masterSpreads. item(0).pages.length > 1){
             document.masterSpreads. item(0).pages.item(-1).remove();
      }
                     
          
          mastertextFrames = document.masterSpreads.item(0).textFrames.add();
          mastertextFrames.geometricBounds=  [(height - 40), (width-40), (height-20), (width -20)];
          mastertextFrames.contents=SpecialCharacters.AUTO_PAGE_NUMBER; 
      
      

       

      When I open the document with InDesign, I still can see 2 pages in the A-Master, and also in the first page, the page number is not well positioned.

       

      Can anyone help please?

       

      Thanks in advacanced,

       

      Davidpage_1.pngpage_2.png

        • 1. Re: Setting MasterSpread to single-sided page and Page Number
          Jump_Over Level 5

          Hi,

           

          Suggest to use documentPreset:

           

          var 
               mPreset = app.documentPresets.add({
                  pageHeight: height,
                  pageWidth: width,
                  facingPages: false,
                  pagesPerDocument: pageNumber
                    }),
               document = app.documents.add(true, mPreset),
               mastertextFrames = document.masterSpreads.item(0).textFrames.add();
          
          mastertextFrames.geometricBounds=  [(height - 40), (width-40), (height-20), (width -20)];
          mastertextFrames.contents=SpecialCharacters.AUTO_PAGE_NUMBER; 
          mPreset.remove();     // or not...
          

           

          // height, width, pageNumber are well defined

           

          Jarek

          • 2. Re: Setting MasterSpread to single-sided page and Page Number
            Laubender Adobe Community Professional & MVP

            @David – I do not have InDesign Server installed so cannot know if the following is working:

             

            app.documents.add({
            
                documentPreferences:{
                    facingPages:false
                    }
            
                });
            

             

             

            If not you can try with app instead of document:

             

            app.documentPreferences.facingPages = false;
            app.documents.add();
            

             

            But be aware that not facing pages is now the default!

             

            Uwe

             

            //EDIT: one comma too much in the first snippet. Corrected.

             

            Message was edited by: Laubender

            1 person found this helpful
            • 3. Re: Setting MasterSpread to single-sided page and Page Number
              DavidFdezGlez Level 1

              Hi, thanks

               

              Finally this worked (Indesign CS6)

               

              var mPreset = app.documentPresets.add({

                      pageHeight: height,

                      pageWidth: width,

                      facingPages: false,

                      pagesPerDocument: pageNumber,

                    });

                   

                   

                  var document = app.documents.add(mPreset);

                    

                  var mastertextFrames = document.masterSpreads.item(0).textFrames.add();