1 Reply Latest reply on May 13, 2014 8:05 AM by Scorpio17523

    Javascript help for Inserting Pages

    Scorpio17523 Level 1

      First of all, thank you to everyone helping me try to work this out.

      Please be patient with me as I'm new to scripting and a complete beginner that only understands the basics.


      Ok, so, I'm working on a side project for where I work. The aim is to develop a script that will allow users to run it and automatically add 4 pages at a time. These pages will be in Spreads (Facing pages).


      We (the company) print booklets of a sort, and due to printing in Printers Spreads, this is how all our templates are setup. This isn't necessarily how it should be done, or how I would setup the templates, but that's how it is and I have to work with what I have.


      Due to this, I can't use the build in feature that is already in InDesign for Smart Text Reflow, but this is basically what I set out to achieve.


      I have been looking around the Internet for a while and found a few different scripts that are already out there that work to a certain degree, but not exactly how I need them to work.


      Below I will demonstrate what I would like to achieve:


      Below is an example of how we have our template set up.


      Screen shot 2014-05-13 at 15.02.27.pngScreen shot 2014-05-13 at 15.02.35.png



      All the scripts I have found and tried to adapt to what I want seem to do the following actions:


      Screen shot 2014-05-13 at 15.02.55.png


      All they will do is add one page at a time and in the wrong place (this should be on the left, NOT the right).


      Screen shot 2014-05-13 at 15.03.20.pngScreen shot 2014-05-13 at 15.03.24.png



      When adding the second page (via the menu interface or by editing any script I find) the second page gets added like this:


      Screen shot 2014-05-13 at 15.03.36.pngScreen shot 2014-05-13 at 15.03.39.png



      Now I already know that this is due to how we have our templates setup, but I can't change that!


      However, if the following functions is used via the interface menu, then the results work perfectly:


      Screen shot 2014-05-13 at 15.03.52.png

      Screen shot 2014-05-13 at 15.04.09.png


      Screen shot 2014-05-13 at 15.04.28.pngScreen shot 2014-05-13 at 15.04.18.png



      It's this function I'd like to reproduce but in script form:


      Pages 4

      At End of Document.


      If anyone could help shed some light on this, it would be extremely beneficial.


      Current examples of scripts I've been experimenting with are:


      myDocument = app.activeDocument
      myDocument.spreads.item(1).allowPageShuffle = true;
      var page=myDocument.spreads.item(1).pages.item(1);
      var pages= myDocument.pages.add(LocationOptions.atEnd);
      var pages= myDocument.pages.add(LocationOptions.atEnd);
      myDocument.spreads.item(1).allowPageShuffle = false;


      Again, thank you in advance.