3 Replies Latest reply on Jul 7, 2013 1:03 AM by AnuragPrism

    If text box content is null/empty, how to identify that?

    virender_CTS

      Dear all,

      i am using a script to read the data from each textbox in a document but my document has some empty blank textbox which I dont want to include because they produce error.

       

      virender

       

      var mydoc = app.activeDocument;

       

      for (i=0; mydoc.stories.length; i++)

       

      {

        var mystory = mydoc.stories[i];

        

           if (mystory[i]== null)  // need coding here ????

           {

           alert("text box is empty")

          }

       

      }

        • 1. Re: If text box content is null/empty, how to identify that?
          Sajeev Sridharan Level 4

          Try this,

           

          var stories = app.documents[0].stories.everyItem().getElements();

          for(var i=0;i<stories.length;i++){

            if(stories[i].contents==""){

              var containers = stories[i].textContainers;

                containers[0].select();

                alert("text box is empty");

              }

            }

           

           

          Vandy

          • 2. Re: If text box content is null/empty, how to identify that?
            virender_CTS Level 1

            Dear Vendy,

             

            thanks it worked here as well. if you could also explain why "0" is present in this statements => containers[0].select();

             

            just want to understand.

             

            Virender

            • 3. Re: If text box content is null/empty, how to identify that?
              AnuragPrism

              Hi ,

              I need one help from you so let me give an overview of what I am looking for and request you to give a solution if possible

              Problem Summary:
              I have an InDesign Template file which is used for a magazine (automated),  ie the data for the magazine would come from other source and we are importing the data as XML to the template and start edits on the imported InDesign file.

              Now the real issue is, since we are suing XML, we have kept a page mapping in the XML as an attribute, ie copy the page number which is available in the InDesign page right bottom and paste the same in XML page number attribute. Since this is a manual process whenever there is a change in XML Template (add a new page or remove a page) we had to manually change the page number attribute which is tedious work, instead it would be really great if we can read the page number from the InDesign Template itself and somehow automatically generate the XML page number attribute.

              I hope you understand the issue. Please let me know if you have any solution in your mind

               

              Thanks in advance

               

              Regards,

              Anurag