6 Replies Latest reply on May 16, 2010 10:34 PM by PaulR72

    [JS CS4] Applying just one object on a master to a page

    PaulR72

      Hello all,

       

      I'm using JavaScript to automate a process I do quite a lot. Part of it involves applying just a single text frame on a master to a page. That master is applied to the page, but that particular master text frame will sometimes have been manually deleted from the page before the script runs. Re-applying the whole master is undesirable, for it removes overrides of all items on the page.

       

      Operating on a simple document with one text frame on the master and that text frame deleted from the page, this code:

       

      itemOnMaster.override(targetPage);

       

      unfortunately won't work. It yields the error "The master page item is already overridden on the page." The override() function seems only to override a master item that's already on the page.

       

      Any tips for getting that master page item back on to the page -- as a master page item, and not just a duplicate with no connection to the master?

       

      Bye bye

       

      Paul

        • 1. Re: [JS CS4] Applying just one object on a master to a page
          [Jongware] Most Valuable Participant

          removeOverride?

           

          I've never used this but it sounds like that's what you need here.

          • 2. Re: [JS CS4] Applying just one object on a master to a page
            PaulR72 Level 1

            That's kinda what I thought too. But it only works if the master item has not been deleted from the page or overridden. I've searched through the  PageItems entry in the object model viewer several times, but can't find anything else. I don't want to override the item: I want to reinstate it to the page.

            • 3. Re: [JS CS4] Applying just one object on a master to a page
              [Jongware] Most Valuable Participant

              Hmmm... you could check the 'overridden' property for existing items (it'll only be true if the object was on a master page and also overridden), but that does not work for deleted items. The same goes for 'overriddenMasterPageItem'.

               

              What you need is a list of 'overridden items', which may or may not still be on the page ...

               

              What if you compare the page items on the applied master page against the actual page's masterPageItems?

               

              "masterPageItems [..] The items on a specified document page that originated on the applied master page and have not been overridden or detached" (my emphasis)

               

              The difference should be something that has been overridden or removed ... I think ...

              • 4. Re: [JS CS4] Applying just one object on a master to a page
                PaulR72 Level 1

                Thanks for your posts, Jongware.

                 

                I don't think that page.masterPageItems  will help, because it's a list of overridden and detached items, not  deleted ones. It won't help to 'undelete' the master item, or to re-apply that specific master item to the document's page, without re-applying the whole master.

                 

                I think I might have to give up and just duplicate the master item  onto the document pages where it's been deleted, and just live with its  not being a part of the master page any more -- just means that any  future changes to those objects would have to be done manually.

                 

                I guess it makes sense that you can't re-instate just one item from a master onto a page, because you can't do it manually using InDesign's UI. It's all or nothing!

                • 5. Re: [JS CS4] Applying just one object on a master to a page
                  Harbs. Level 6

                  If a page item is detached from the master, there's nothing connecting to to the master, so short of comparing the bounds or some other property, there's no way of knowing what master item it originated from.

                   

                  If you are not dealing with detached items (only overridden or deleted items, then you can iterate through all the page items and if none are based on your master item (or if none of the page.masterPageItems are your item), it was deleted.

                   

                  FWIW, If you want something to take care of reapplied master pages, you might want to check out AutoFlow Pro.

                   

                  Harbs

                  • 6. Re: [JS CS4] Applying just one object on a master to a page
                    PaulR72 Level 1

                    Thanks Harbs. Sounds like there is no way of restoring a master page item that's been deleted from a page, by script. I'll just duplicate the master object onto the page.