6 Replies Latest reply on May 9, 2008 4:00 AM by (Gunasekaran)

    Placing Figures

      Hi All,

      This is Guna from chennai, I wrote the JavaScript to place the figures automatically on each of te page. But this script will be placing the figures in top of the page. my code is:

      var myFolder = Folder("/d/Photos/Links/")

      myFiles = myFolder.getFiles("*.tif");
      myFiles = myFiles.sort();

      //Counting the Files
      for (var i = 0; i < myFiles.length; i++) {
      var myDocument = app.documents.item(0);
      var myPage = myDocument.pages.add()
      var myGraphic = myDocument.pages.item(i).place(File(myFiles[i]));
      }

      Can you any one help me, how to place the these objects in top / left margin position?

      Thanks in advance
      Gunasekaran
        • 1. Re: Placing Figures
          Level 1
          you need to move object after place (I'm not JS man):

          myX = myPage.bounds(1)+myPage.marginLeft
          myY = myPage.bounds(0)+myPage.marginTop

          myGraphic.Move([myX,myY])

          robin

          --
          www.adobescripts.com
          • 2. Re: Placing Figures
            Level 1
            <DIV><FONT face=Arial size=2>Hi Robin,</FONT></DIV><br /><DIV><FONT face=Arial size=2></FONT> </DIV><br /><DIV><FONT face=Arial size=2>Thanks for your swift response, unfortunately this <br />code is not working. Could you look in to my code and let me know if I am <br />wrong.</FONT></DIV><br /><DIV><FONT face=Arial size=2></FONT> </DIV><br /><DIV><FONT face="Courier New" size=2> var myGraphic = <br />myDocument.pages.item(i).place(File(myFiles[i]));</FONT></DIV><br /><DIV><FONT face="Courier New" size=2></FONT> </DIV><br /><DIV><FONT face="Courier New" size=2> myX = <br />myPage.bounds(1)+myPage.marginLeft<BR> myY = <br />myPage.bounds(0)+myPage.marginTop</FONT></DIV><br /><DIV><FONT face="Courier New" size=2></FONT> </DIV><br /><DIV><FONT face="Courier New" <br />size=2> myGraphic.Move([myX,myY])</FONT></DIV><br /><DIV><FONT face=Arial size=2></FONT> </DIV><br /><DIV><FONT face=Arial size=2>I am expecting the graphic files to be placed in <br />top / left margin. I have tried too many ways placing this way. Could you advise <br />is any tools was available to paginate the XML files automatically i.e. placing <br />the figures, tables, equations automatically and adjusting the vertical <br />justification of elements.</FONT></DIV><br /><DIV><FONT face=Arial size=2></FONT> </DIV><br /><DIV><FONT face=Arial size=2>Thanks in advance.</FONT></DIV><br /><DIV><FONT face=Arial size=2>Guna<BR></FONT></DIV><br /><DIV><FONT face=Arial size=2>----- Original Message ----- </FONT><br /><DIV><FONT face=Arial size=2>From: "Robert_Tkaczyk" &lt;</FONT><A <br />href="mailto:member@adobeforums.com"><FONT face=Arial <br />size=2>member@adobeforums.com</FONT></A><FONT face=Arial <br />size=2>&gt;</FONT></DIV><br /><DIV><FONT face=Arial size=2>To: &lt;</FONT><A <br />href="mailto:adobe.scripting.indesign@adobeforums.com"><FONT face=Arial <br />size=2>adobe.scripting.indesign@adobeforums.com</FONT></A><FONT face=Arial <br />size=2>&gt;</FONT></DIV><br /><DIV><FONT face=Arial size=2>Sent: Friday, May 09, 2008 4:03 PM</FONT></DIV><br /><DIV><FONT face=Arial size=2>Subject: Re: Placing Figures</FONT></DIV></DIV><br /><DIV><FONT face=Arial><BR><FONT size=2></FONT></FONT></DIV><FONT face=Arial <br />size=2>&gt;A new message was posted by Robert_Tkaczyk in<BR>&gt; <BR>&gt; <br />InDesign Scripting --<BR>&gt;  Placing Figures<BR>&gt; <BR>&gt; you need to <br />move object after place (I'm not JS man):<BR>&gt; <BR>&gt; myX = <br />myPage.bounds(1)+myPage.marginLeft<BR>&gt; myY = <br />myPage.bounds(0)+myPage.marginTop<BR>&gt; <BR>&gt; <br />myGraphic.Move([myX,myY])<BR>&gt; <BR>&gt; robin<BR>&gt; <BR>&gt; -- <BR>&gt; <br /></FONT><A href="http://www.adobescripts.com"><FONT face=Arial <br />size=2>www.adobescripts.com</FONT></A><BR><FONT face=Arial size=2>&gt; <BR>&gt; <br /><BR>&gt; ------------------------------------------------------<BR>&gt; <br />View/reply at &lt;</FONT><A <br />href="http://www.adobeforums.com/webx?13@@.59b5338a/0"><FONT face=Arial <br />size=2>http://www.adobeforums.com/webx?13@@.59b5338a/0</FONT></A><FONT <br />face=Arial size=2>&gt;<BR>&gt; Replies by email are OK.<BR>&gt; Use the <br />unsubscribe form at &lt;</FONT><A <br />href="http://www.adobeforums.com/webx?280@@.59b5338a!folder=.eea52bc"><FONT <br />face=Arial <br />size=2>http://www.adobeforums.com/webx?280@@.59b5338a!folder=.eea52bc</FONT></A><FONT <br />face=Arial size=2>&gt; to cancel your email subscription.</FONT>
            • 3. Re: Placing Figures
              Level 1
              maybe this:

              var myFolder = Folder("/d/Photos/Links/")

              myFiles = myFolder.getFiles("*.tif");
              myFiles = myFiles.sort();

              //Counting the Files
              for (var i = 0; i < myFiles.length; i++)
              {
              var myDocument = app.documents.item(0);
              var myPage = myDocument.pages.add();
              var myGraphic = myDocument.pages.item(i).place(File(myFiles[i]));
              myX = myPage.bounds(1) + myPage.marginPreferences.left;
              myY = myPage.bounds(0) + myPage.marginPreferences.top;
              myGraphic.Move([myX,myY]);
              }

              robin

              --
              www.adobescripts.com
              • 4. Re: Placing Figures
                Level 1
                Dear Robin,

                Rightnow, Im using the InDesign CS2 in IBM PC and tried this code also in
                CS3 but this code is not working. I have written some more lines after the
                placing the figures (i.e. placing the captions) but these line are not
                executed. It would be very thankful if anyone give feasible solution on
                this.

                Best,
                Guna
                • 5. Re: Placing Figures
                  Level 1
                  what error messages ?

                  robin

                  --
                  www.adobescripts.com
                  • 6. Re: Placing Figures
                    Level 1
                    Dear Robin,


                    There is none of the error messages displayed on that code! but after this
                    line var myGraphic = myDocument.pages.item(i).place(File(myFiles[i])); no
                    codes executed.


                    Best,
                    Guna