3 Replies Latest reply on Dec 12, 2014 4:28 AM by Adobe-InDesign CS4

    move text box to library item

    ASHOK KUMAR Level 1

      Dear All


      Please refer my screen shot.


      I want my all ce:textbox move out in Structure. When ce:textbox move in page and place into Box library item (like “BOX_1COL”).

      Box.jpg

       

      You have any script code.


      Thanks

      ASHRAM

        • 1. Re: move text box to library item
          Adobe-InDesign CS4

          Dear Ashram,

           

          Please use the below source Code, this would helps to resolve your problem

           

          //============================ Script Starts ==========================

          var myDoc  = app.documents[0];

           

          //Use Glue Code  :   Call the Glue Code.jsx script " //

          __PlacementXML(myDoc);

           

           

          function __PlacementXML(myDoc)

          {

            try

                {

                       var elementXpathBx = "//textbox";

                      var myRuleSet = new Array (new __PlacementXMLElms(elementXpathBx));

                      with(myDoc){

                          var elements = xmlElements;

                          var myRet =   __processRuleSet(elements.item(0), myRuleSet);

                          }

                }catch(e)

                 {

                       

                     }

          }

          }

           

           

          function  __PlacementXMLElms(ElmS)

          {

            this.name = "McGrawHill_DisPlayFigure Placement";

                  this.xpath = s1;   

                  this.apply = function(myElement, myRuleProcessor){

                      with(myElement){

                              try{

                             

                                  var myDoc = app.documents[0];

           

                                  var iLibrary = app.libraries.item("abc.indl");

           

                                   var iLibItemBoxName =iLibrary.assets.item("Box_1Col");

           

                                   var iLibAsset = iLibItemBoxName.placeAsset (myDoc);

           

                                  iLibAsset.placeXML(myElement)

           

                               }catch(e)

                                  {

                                  }

                           }

                 }

          }

           

          //============================ Script End==========================

           

          Thanks & Regards

          T.R.Harihara SudhaN

          • 2. Re: move text box to library item
            ASHOK KUMAR Level 1

            Dear Hari

             

            Thanks for your coding. I filled xpath and run this script. But it is not working. The structure text box text not place in library item. Library box item only place in page. Please check.

             

            My XML code is :

            <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

            <chapter xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ce="http://www.elsevier.com/xml/common/dtd" xmlns="http://www.elsevier.com/xml/ehs-book/dtd" xml:lang="en" id="xxxxx" docsubtype="chp" version="5.1" xmlns:sb="http://www.elsevier.com/xml/common/struct-bib/dtd" xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><!--<info><ce:pii>xxx-x-xxxx-xxxx-x.xxxxx-x</ce:pii><ce:doi>xx.xxxx/xxxx-x-xxxxx-xxxx-x. xxxxx-x</ce:doi><ce:isbn>xxx-x-xxxx-xxxx-x</ce:isbn><ce:copyright type="full-transfer" year="2008">Elsevier Inc.</ce:copyright></info>--><ce:floats></ce:floats><!--<ce:label>Chapter xxx</ce:label>--><ce:title aid:pstyle="Chap title">xxxxxxxxx</ce:title><ce:author-group><ce:author id="au0005" aid:pstyle="Chap au"><ce:given-name>xxxxxx</ce:given-name> <ce:surname>xxxxx</ce:surname></ce:author></ce:author-group><ce:sections><ce:para view="all" id="p0605">Sweeping demographic change has meant that older people now represent the core practice of medicine in many countries. The terms ‘chronological’ and ‘biological’ ageing have been coined to describe this phenomenon. Biological rather than chronological age is taken into consideration when making clinical decisions about, for example, the extent of investigation and intervention that is appropriate.</ce:para>

            <ce:textbox id="b0010" aid:pstyle="B title"><ce:label>7.2</ce:label> <ce:caption><ce:simple-para view="all" id="sp0035">Domains impaired in frailty</ce:simple-para></ce:caption>?<ce:textbox-body><ce:sections><ce:para view="all" id="p0010" aid:pstyle="B text"><ce:list id="l0005"><ce:list-item id="u0005"><!--<ce:label>&bull;</ce:label>--><ce:para view="all" id="p0015" aid:pstyle="B bull list flush">Musculoskeletal function</ce:para></ce:list-item>?<ce:list-item id="u0010"><!--<ce:label>&bull;</ce:label>--><ce:para view="all" id="p0020" aid:pstyle="B bull list flush">Aerobic capacity, i.e. cardiorespiratory function</ce:para></ce:list-item>?<ce:list-item id="u0015"><!--<ce:label>&bull;</ce:label>--><ce:para view="all" id="p0025" aid:pstyle="B bull list flush">Cognitive function</ce:para></ce:list-item>?<ce:list-item id="u0020"><!--<ce:label>&bull;</ce:label>--><ce:para view="all" id="p0030" aid:pstyle="B bull list flush">Integrative neurological function (e.g. balance and gait)</ce:para></ce:list-item>?<ce:list-item id="u0025"><!--<ce:label>&bull;</ce:label>--><ce:para view="all" id="p0035" aid:pstyle="B bull list flush">Nutritional status</ce:para></ce:list-item></ce:list></ce:para></ce:sections></ce:textbox-body></ce:t extbox>

             

             

            My script coding is:

            var myDoc  = app.documents[0];

            #include "C:/Program Files (x86)/Adobe/Adobe InDesign CS6/Scripts/Xml Rules/glue code.jsx" 

            __PlacementXML(myDoc);

             

            function __PlacementXML(myDoc)

            {

              try

                  {

                         var elementXpathBx = "//textbox";

                        var myRuleSet = new Array (new __PlacementXMLElms(elementXpathBx));

                        with(myDoc){

                            var elements = xmlElements;

                            var myRet =   __processRuleSet(elements.item(0), myRuleSet);

                            }

                  }catch(e)

                   {

                       

                       }

            }

             

              function  __PlacementXMLElms(ElmS)

            {

              this.name = "Textbox placement";

                    this.xpath = "/chapter/textbox"; 

                    this.apply = function(myElement, myRuleProcessor){

                        with(myElement){

                                try{

                             

                                    var myDoc = app.documents[0];

             

                                    var iLibrary = app.libraries.item("ANNO.indl");

             

                                     var iLibItemBoxName =iLibrary.assets.item("Box");

             

                                     var iLibAsset = iLibItemBoxName.placeAsset (myDoc);

             

            iLibAsset.placeXML(myElement)

             

                                 }catch(e)

                                    {

                                    }

                             }

                   }

            }

             

             

            Please check and correct my script.

             

            Thanks

            ASHRAM

            • 3. Re: move text box to library item
              Adobe-InDesign CS4 Level 1

              Dear ASHRAM,

               

              Yes I understand,

               

                           //===============================================//

                 

                                var iLibrary = app.libraries.item("ANNO.indl");

               

                                       var iLibItemBoxName =iLibrary.assets.item("Box");

               

                                       var iLibAsset = iLibItemBoxName.placeAsset (myDoc);

               

                                    app.select(iLibAsset);

                 

                                   var idSelection = app.selection[0];

                 

                                         idSelection.placeXML(myDoc.xmlElements[0])

               

                                        //=============================================//

               

              Please use the above code, this will helps to resolve your problem

               

               

              Thanks & Regards

              T.R.Harihara SudhaN