2 Replies Latest reply on May 23, 2014 2:40 AM by hurix@123

    Again Library Item

    hurix@123 Level 1

      Hi All,

       

      I have coding to place Library Item into the Page Layout, my Script placing the library Item into that parent Page,

       

      But my Problem is I can not place XMLElement Into that Library Element Box.

       

      Here is my Script:

       

      myDoc.select(myElement);          

                  var mySideBarXML = app.selection[0];

                  try  {

                                      myAsset = myCurrentLib.assets.item("Box");   // Name of the library item is "bx1"

                      myLibraryItem = myAsset.placeAsset(myElement.insertionPoints[-1]);

        catch (err)   {

                      alert ("There is no library element with the name Box");

                      exit();

                      }

       

                  // TO PLACE TEXT IN LIBRARY ITEM

                try {

                      myLibraryItem[0].textFrames[0].placeXML(mySideBarXML);   // if the library element is group of frames.

                                    }

                  catch (ee)  {

                      try {

                          myLibraryItem[0].placeXML(mySideBarXML);   // if the library element is a single frame.

                          }

                      catch (ee) { }

                       

                      }

                                           }

       

      can any one help on this.

       

      Regards

      Hurix

        • 1. Re: Again Library Item
          csm_phil Level 4

          Hi hurix,

           

          Are you try the above requirement in manually, You can't do even manually, because you already placed the library item into the XML text in between, again you drag the you respective box element xml text into the box, definitely its shown the error in InDesign like this...("Elements cannot be placed into an inline").

           

          Now, what you have to do it for your requirement to meet. First you placed the library item into the respective page, then placed the box xml element content into the library item text frame.

           

          try{
              var mySideBarXML = myElement;
              var myLibraryItem = app.libraries[0].assets.item("Box").placeAsset(myDoc)[0];// here you give the page, i.e., you selection element text parent page;
              myLibraryItem.move(mySideBarXML.xmlContent.parentTextFrames[0].parentPage);
               try {
                   myLibraryItem.textFrames[0].placeXML(myElement);   // if the library element is group of text frame.
                   }
               catch (ee) {
                   myLibraryItem.placeXML(myElement);// single text frame no group.
                   }                        
          

           

          thx,

          csm_phil,

          • 2. Re: Again Library Item
            hurix@123 Level 1

            Hi csm_phil,

             

            Thanks for your reply,

             

            It works Fine.

             

            thanks

            hurix