1 Reply Latest reply on Jul 22, 2012 3:59 PM by Marc Autret

    Properties of page items in the master page

    BreachofMind

      Hello scripters,

      I've ran into an odd issue that I can't figure out. I'm writing a script that will dynamically place merged records into custom placeholders. The placeholders are on a separate, non-printing layer contained in the master page (since you can't merge records properly if they aren't). Each document the script runs on is 1 page long.

       

      The script is quite simple; it extracts the geometricBounds properties of each custom placeholder textframe and adds it to an array:

       

      function FindOrder (orderItems) { // takes an array of textframes

          for (var i = orderItems.length-1; i >= 0; i--) {

              var o = new Object();

              o.gb = orderItems[i].geometricBounds;  // <---------------------

              o.num = orderItems.length-i;

              o.topleft = [o.gb[0],o.gb[2]];

              order.push (o);

              }

          }

       

      Once the document merges, it sets the merged records geometricBounds property to the custom placeholder .gb property:

       

      for (var i = mergeItems.length-1; i >= 0; i--) {mergeItems[i].geometricBounds = order[i].gb};

       

      I run into the problem when I try to populate the "orderItems" array with the placeholder textframes:

       

      var orderLayer = app.activeDocument.layers.itemByName('order');

      var orderItems = orderLayer.textframes;

      $.writeln(orderItems.length); // < <--------------------- this will output "0" !!!!

       

      Since the placeholders are on the master page, the script can't find them. When I try putting them on the layout page, then they will show up. But, in order for the script to work properly, they need to be on the master.

       

      Any ideas? I'm pulling them from the 'order' layer because they must be in order. Otherwise, when the document is merged, the script might put the data out of sequence.

       

      Thanks...

      Mike