9 Replies Latest reply on Jun 4, 2011 8:55 AM by Mac_06

    [JS CS5] Wrong placement of file on recto page

    Mac_06 Level 2

      I am wondring the way around but not seem to resolve the correct placement of file while it is a recto page.

      I have multipage document where I need to place some files(i.e. eps, idms). For that X and Y coordinates are given but incase of recto page the position of placed files are not correct.

       

      page ruler origin should work for place or add any page item similer way but here for placing any file it's giving me wrong placement.

       

       var theDoc = app.activeDocument, curPage, leftMargin, topMargin, pageBounds, pageWidth, theYpos, theXpos, theHeight, theWidth, snippetFile, theBag;
       theDoc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
       curPage = theDoc.pages[1];
       leftMargin = curPage.marginPreferences.left;  
       topMargin = curPage.marginPreferences.top;  
       pageBounds = curPage.bounds; 
       pageWidth = pageBounds[3]-pageBounds[1];                   
       theYpos = topMargin+  240;
       theXpos = leftMargin + 0 ;
       theHeight = theYpos + 60 ;
       theWidth = theXpos+100;
       snippetFile = File("/C/Image/Lorem.idms")
       theBag= curPage.place(snippetFile, {geometricBounds:[theYpos,  theXpos, theHeight,  theWidth]});
                  
      

       

      I am not sure whether this a bug or what am I missing out here.

       

      Thanks

      Mac

        • 1. Re: [JS CS5] Wrong placement of file on recto page
          csm_phil Level 4

          Hi Mac,

           

          You try this js code:

           

          var theDoc = app.activeDocument;
          theDoc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;

           

          //mentioned the page number inside the pages[]
          curPage = theDoc.pages[1];

           

          var myActivePage = app.layoutWindows[0].activePage = curPage;
          if(myActivePage.side == PageSideOptions.rightHand){
              alert("RECTO");

              //you can change the image position into the geometricBounds value of recto page
              theBag= curPage.place(File("/C/Image/Lorem.idms"), {geometricBounds:[75,50,25,100]});
              }
          else {
              alert("VERSO");

              //you can change the image position into the geometricBounds value of verso page
              theBag= curPage.place(File("/C/Image/Lorem.idms"), {geometricBounds:[36,75,50,100]});
              }

           

          thx

          csm_phil

          • 2. Re: [JS CS5] Wrong placement of file on recto page
            Mac_06 Level 2

            thanks for quick reply csm_phil but it goes fail incase of spread which is the main issue for me since my document having facing pages only.

            So though our geometric bounds are for recto page and ruler origin is page origin but still the placement is done at verso page, the same as with my code.

             

            again thanks for taking interest in.

            Mac

            • 3. Re: [JS CS5] Wrong placement of file on recto page
              csm_phil Level 4

              Hi Mac,

               

              If you dont mine can you post your documen snapshot because i want to update my script clearly.

               

               

              ASAP.

               

              thx

              csm_phil

              • 4. Re: [JS CS5] Wrong placement of file on recto page
                Mac_06 Level 2

                Oops cms_phil, I tried a lot to upload image but I am getting error massage from the site that "Image content is not valid". I don't know why, I tried with several format like bmp, eps, tiff, psd, doc but the same error.

                 

                hmm, let me try to understand you by black & white only.

                 

                Create a new Indd document with facing page (Left and Right both side document page).

                and as you could see in my code I'm trying to place an idms file on recto page (2nd count of page as first is verso page).

                run my code as you could see even the origin of document is page origin and but still it is placing the file on verso(Left hand side) page.

                 

                But wait here is a twist, add below fragment with my code and Run-:

                 

                currentINDDPage.rectangles.add({geometricBounds:[theYpos,  theXpos, theHeight,  theWidth]});

                 

                You will be able to see, Though the geometric bounds are same for both Items but rectangle is placed on recto(Right hand side) page.

                 

                Is this a bug?

                 

                 

                Thanks

                Mac

                • 5. Re: [JS CS5] Wrong placement of file on recto page
                  csm_phil Level 4

                  Hi Mac,

                   

                  I suggest you upload the png file format or just InDesign Document create the snapshot and page into the direct onto the post.

                   

                  Ok Mac you try this its working for me good.

                  Please check and revert.

                   

                  var theDoc = app.activeDocument, curPage, leftMargin, topMargin, pageBounds, pageWidth, theYpos, theXpos, theHeight, theWidth, snippetFile, theBag;
                  theDoc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
                  curPage = theDoc.pages[2];
                  leftMargin = curPage.marginPreferences.left; 
                  topMargin = curPage.marginPreferences.top; 
                  pageBounds = curPage.bounds;
                  pageWidth = pageBounds[3]-pageBounds[1];                  
                  theYpos = topMargin+  240;
                  theXpos = leftMargin + 0 ;
                  theHeight = theYpos + 60 ;
                  theWidth = theXpos+100;
                  snippetFile = File("~/Desktop/1.inds");

                   


                  var myActivePage = app.layoutWindows[0].activePage = curPage;
                  if(myActivePage.side == PageSideOptions.rightHand){
                      alert("RECTO");
                      theBag = curPage.place(snippetFile, [leftMargin,topMargin]);
                      }
                  else {
                      alert("VERSO");
                      theBag = curPage.place(snippetFile, [leftMargin,topMargin]);
                      }

                   

                  thx

                  csm_phil

                  • 6. Re: [JS CS5] Wrong placement of file on recto page
                    John Hawkinson Level 5

                    Mac_06 wrote:

                     

                    Oops cms_phil, I tried a lot to upload image but I am getting error massage from the site that "Image content is not valid". I don't know why, I tried with several format like bmp, eps, tiff, psd, doc but the same error.

                    PNG or GIF.

                    • 7. Re: [JS CS5] Wrong placement of file on recto page
                      csm_phil Level 4

                      Hi Mac,

                       

                      Have you tried my js code or not?

                       

                      i am waiting for you reply. because the thread is look like still not answer.

                       

                      thx

                      csm_phil.

                      • 8. Re: [JS CS5] Wrong placement of file on recto page
                        Mac_06 Level 2

                        Sorry, for delay csm_phil I was on OOO yesterday so I couldn't check the

                        code.

                         

                        Now it is tested on few scenario and it is working as expected.

                        Thanks you for great help.

                        • 9. Re: [JS CS5] Wrong placement of file on recto page
                          csm_phil Level 4

                          Hi Mac,

                           

                          It's okay your expetation i will full fill.

                           

                          Can you please update this thing 1 "correct" answer available (10 pts) 2 "helpful" answers available (5 pts).

                          Because the your post threat is not answerd so lot of people open and read the wast time.

                           

                          thx

                          csm_phil