1 Reply Latest reply on Jul 12, 2012 11:57 AM by Gonterman1201

    Keeping track of document size throughout the course of a script

    alexthebake Level 1

      Hi,

       

      I have a somewhat theoretical question.

      I'm making a fairly large script that does many different operations to automate the workflow of my co-workers.

      However, some of these operations require that I change the document size. The problem is that all the different operations happen in sequence, so changing the doc size can be tricky when some operations work off of the current doc size.

       

      At first, I was only resizing pages, which made the problem easy to solve because it came down to what order all the operations happen in.

       

      However, now, they've asked that instead of changing the page size, I change the document size. This is fine, except for the fact that changing the document size does not allow you to choose an anchor point from which to make the change. This is a problem because if some operations have already been completed, and then another operation changes the document size, all of the elements added in previous operations are now in the wrong spot, and the whole thing is thrown off.

       

      My first ideas for solving this problem were to change the document size either at the very beginning or at the very end. These solutions seemed to almost work, but they make it hard to perform operations that are based on the document size before it is changed.

       

      My question (or discussion) is: When working with a script that requires multiple Document size changes, what is the best way to go about it? How do I keep track of the page size and maintain the accuracy of all the operations.

       

      *operations: I'm using this term lightly, to mean "function" or procedure.

        • 1. Re: Keeping track of document size throughout the course of a script
          Gonterman1201 Level 1

          i was thinking you could do something like this to find the document size and then adjust according to the size of the document by maybe changing its location or its bound just depending on what your  moving but first you have to know the size of the doc.

           

          var myDoc = app.activeDocument;

          var myPageSize=myDoc.pages.item(0).bounds;

          var top=myPageSize[0];

          var left=myPageSize[1];

          var bottom=myPageSize[2];

          var right=myPageSize[3];

          var width=right-left;

          var height=bottom-top;

           

          Then adjust.