0 Replies Latest reply on Jun 10, 2010 10:35 PM by richardh6

    [CS4/JS] Problem moving pages -- they're losing their connections to sections

    richardh6 Level 1

      I've encountered something I think might be a bug in InDesign.  It's actually not strictly a scripting problem -- I discovered it while debugging a script, but it happens in the user interface as well.  The easiest way for me to explain it is with a script, though.

       

      The problem is this:  When you have two pages that have the same page number but different page number styles, and one of them is the first page of the document, and they're both the beginning of their own sections (and continueNumbering is off for both), they should stay the way they are when you move them, but they don't.  The page that was first and is now second loses its connection to its section, and becomes an automatic page number following the first page.

       

      The following script will set up just such a document and illustrate the problem:

       

      // Start a new document with two pages, each the start of its own section.
      // They are each page 1, but one of them is numbered with Arabic numerals,
      // the other with lower-case Latin letters.
      var doc = app.documents.add();
      
      var page1 = doc.pages[0];
      var section1 = page1.appliedSection;
      section1.continueNumbering = false;
      section1.pageNumberStart = 1;
      section1.pageNumberStyle = PageNumberStyle.ARABIC;
      
      var pageA = doc.pages.add(LocationOptions.AT_END);
      var sectionA = doc.sections.add (pageA);
      sectionA.continueNumbering = false;
      sectionA.pageNumberStart = 1;
      sectionA.pageNumberStyle = PageNumberStyle.LOWER_LETTERS;
      
      alert ("At this point we should have a document with two pages, " +
                "numbered 1 and a.  The page numbers are fixed, " +
                "so that if we move them, they should stay 1 and a.");
      
      page1.move(LocationOptions.AFTER, pageA);
      
      
      alert ("Now look at what happened:  we did a simple " +
                "page1.move(LocationOptions.AFTER, pageA); " +
                "and page1 lost its section and is " +
                "being automatically numbered after pageA.");
      

       

      I realize this is sort of an obscure scenario, but I'm trying to write a script that takes pages from different documents and fixes the page numbers (i.e., makes them all the beginnings of their own sections and turns off continueNumbering) and puts them together in one new document in order of page number.  I want it to cover all possible situations, so it might as well cover the one I'm describing above.