10 Replies Latest reply: Aug 30, 2011 12:00 AM by Sergey Anosov RSS

    [JS][CS5] resize document

    Roy Marshall Community Member

      Hi

       

      Part of a script I am writing resized the active doc to the width and height of the selected frame. However, I cannot seem to get InDesign to reduce the page size to anything leaas that 20.5mm.  There are no guides set, there is nothing on the master page either.

      If I manually change the page size, to the sam measurements it is all OK.

       

      myWidth = mySelection[0].geometricBounds[3] - mySelection[0].geometricBounds[1];
      myHeight = mySelection[0].geometricBounds[2] - mySelection[0].geometricBounds[0];
      myDoc.documentPreferences.pageWidth = myWidth;
      myDoc.documentPreferences.pageHeight = myHeight;
      

       

      the error is :

      Error, data is out of range.

       

      I know I must be doing something bumb, so please tell me!!

       

      Roy

        • 1. Re: [JS][CS5] resize document
          Harbs. CommunityMVP

          Set the margins to 0

           

          Harbs

          • 2. Re: [JS][CS5] resize document
            Roy Marshall Community Member

            Thanks Harbs, but I already set them all to 0. The weird thing is I 

            can change the size in InDesign itself to the value needed without any 

            problems.

            I have also changed the margins on the master pages too

            Thanks for the suggestion though.

             

            Roy

            • 3. Re: [JS][CS5] resize document
              booyajamo Community Member

              Hi Roy,

               

              I'm having the same problem.  Have you found any solution?  I've been searching the internet and the INDD scripting guides I have and can't find anything.  Hoping you've had luck!

               

              Thanks,

              Lindsay

              • 4. Re: [JS][CS5] resize document
                Roy Marshall Community Member

                Hi Lindsay.

                 

                I managed to get around to getting this sussed.  I think I have it. 

                It is all to do with the application margin preferences, and the document margin preferences.

                 

                My code below does work, and resets the application margins back too which is useful:

                 

                myOldTop = app.marginPreferences.top;
                myOldLeft = app.marginPreferences.left;
                myOldRight = app.marginPreferences.right;
                myOldBottom = app.marginPreferences.bottom;
                
                app.marginPreferences.left = 0;
                app.marginPreferences.right = 0;
                app.marginPreferences.top = 0;
                app.marginPreferences.bottom = 0;
                
                myDoc.marginPreferences.left = 0;
                myDoc.marginPreferences.right = 0;
                myDoc.marginPreferences.top = 0;
                myDoc.marginPreferences.bottom = 0;
                
                myPage = myDoc.pages[0];
                myPage.marginPreferences.left = 0;
                myPage.marginPreferences.right = 0;
                myPage.marginPreferences.top = 0;
                myPage.marginPreferences.bottom = 0;
                
                for(i=0;i<=myMasterSpreads.length-1;i++){
                     myMasterSpread = myMasterSpreads[i];
                     for(x = 0;x<=myMasterSpread.pages.length-1;x++){
                          myMasterSpread.pages[x].marginPreferences.right = 0;
                          myMasterSpread.pages[x].marginPreferences.left = 0;
                          myMasterSpread.pages[x].marginPreferences.top = 0;
                          myMasterSpread.pages[x].marginPreferences.bottom = 0;
                          }
                     }
                //do the stuff you need to do
                
                app.marginPreferences.left = myOldLeft;
                app.marginPreferences.right = myOldRight;
                app.marginPreferences.top = myOldTop;
                app.marginPreferences.bottom = myOldBottom;
                

                 

                All the master spreads margins are changed to 0, the document preferences are changed to 0, and the application preferences are changed to 0.  It looks like all these need to be 0 before you can make the small page size.

                Obviously I have left out the error controls, the actual resizing bit, but this chunk above manages to sort out the page being resized to a small size.

                 

                Let me know if this helps you.

                 

                Roy

                • 5. Re: [JS][CS5] resize document
                  Roy Marshall Community Member

                  also, and I haven't tested this, but I suspect that the application preferences dont need to be changed, just the page, masterpages and document preferences.

                  • 6. Re: [JS][CS5] resize document
                    booyajamo Community Member

                    Hi Roy,

                     

                    Thanks for the response!  Did you see my post here http://forums.adobe.com/thread/892458?tstart=0

                     

                    There are some great solutions there as well.

                     

                    Thanks again!

                    Lindsay

                    • 7. Re: [JS][CS5] resize document
                      Roy Marshall Community Member

                      Ah yes.  The same problem tackled in a slightly different way.  Did you get the answer you were looking for? Were you able to sort out your script?

                       

                      Cheers

                       

                      Roy

                      • 8. Re: [JS][CS5] resize document
                        Sergey Anosov Community Member

                        Hi Roy!

                        Sometimes I need to change document page size according to selection size. Let me offer a script for this case:

                        https://sites.google.com/site/dtpscripting/indesign-scripts/fitpagetoselection-jsx

                         

                        Best wishes,

                        Sergey

                        • 9. Re: [JS][CS5] resize document
                          Roy Marshall Community Member

                          Hi Sergey.

                           

                          Took a look at your site.  Most impressive!  The script I created does what I want, yours is a lot deeper than I needed, but will bear it in mind.

                           

                          I have taken your crop mark script though, I have a basic version, but your is way better!

                           

                          Cheers

                           

                          Roy

                          • 10. Re: [JS][CS5] resize document
                            Sergey Anosov Community Member

                            Okay! You are welcome!