6 Replies Latest reply on Oct 19, 2012 6:46 AM by Sajeev Sridharan

    Figure placement

    hurix@123

      Hi All,

       

      We have more than 100 images need to place in indesign. Every time i need to place the images manualy.

       

      In my Indesign i have a xml tag like <graphics 1> the folowed be the figures caption. my Figure name is Grap01.eps.

       

      Kindly help me how to place the figures using script

       

      Thanks

      Ramki

        • 1. Re: Figure placement
          Sajeev Sridharan Level 4

          var myDoc = app.activeDocument;

          var testElement = myDoc.xmlElements.item(0);

          var testElements = testElement.evaluateXPathExpression("//graphics1");

           

           

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

          {

              var path = document.filePath;

              name = "Grap";

             testElements[i].insertionPoints[0].place (File (path + '/' + name + '.eps'));

          }

           

          Hope this will help you...

           

           

          - Vandy

          • 2. Re: Figure placement
            hurix@123 Level 1

            Hi Vady,

             

            Thank you very much.

             

            I try above code, but it shows "The file path// Grap.eps not found"

             

            var myDoc = app.activeDocument;

            var testElement = myDoc.xmlElements.item(0);

            var testElements = testElement.evaluateXPathExpression("//graphics1");

             

             

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

            {

                var path = document.filePath;

                name = "Grap01";

               testElements[i].insertionPoints[0].place (File (path + '/' + name + '.eps'));

            }

             

            When i try above code 'Grap01' is place all places.

             

            Regards

            Ramakrishna.K

            • 3. Re: Figure placement
              hurix@123 Level 1

              My XML code is:

               

              <graphic src="10.4135_9781412980029-fig1601.jpg" alt="Figure 16.1 Devotees at the Shrine of Data Ganj Bukhsh Lahore."/>

              <graphic src="10.4135_9781412980029-fig1602.jpg" alt="Figure 16.2 Devotees at the Shrine of Data Ganj Bukhsh Lahore."/>

               

              Figure Name: Grap16.1, Grap16.2

               

              Ram

              • 4. Re: Figure placement
                Sajeev Sridharan Level 4

                var myDoc = app.activeDocument;

                var testElement = myDoc.xmlElements.item(0);

                var testElements = testElement.evaluateXPathExpression("//graphic");

                 

                var path = document.filePath;

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

                {

                        attr=testElements[i].xmlAttributes.itemByName("src").value;

                        var testfigName = attr.split("-fig");

                        var figName = testfigName[1].split("0");

                        var figureName = 'Grap' + figName[0] +  '.' + figName[1];

                       

                 

                 

                   testElements[i].insertionPoints[0].place (File (path + '/' + figureName));

                   }

                 

                 

                - Vandy

                • 5. Re: Figure placement
                  hurix@123 Level 1

                  Yes got it.

                   

                  Thank you.

                   

                  Ram

                  • 6. Re: Figure placement
                    Sajeev Sridharan Level 4

                    If my code helps you, make the discussion as answered... dont leave as it is...

                     

                    - Vandy..

                    1 person found this helpful