6 Replies Latest reply on Aug 29, 2012 12:32 PM by lhanneman

    Copy all page items into new document - Invalid parameter? [CS5][JS]

    lhanneman Level 1

      Hello,

       

      I've got four InDesign documents, for simplicity, lets say they are all 5x5 inch (each of the four documents contains 1 5x5inch page). I'm trying to create one, new 10x10inch page by placing my four smaller pages into a 2x2 grid on my new page. What would the best route be to accomplish this in javascript?

       

      What I've tried:

       

      1. In my script creating the new page, I've tried opening each of the 4 other documents as a copy and duplicating the page into my new document. This doesn't seem to be what I want since it treats it as a whole new page in the spread. I really just need to get the content copied over onto my new 10x10 page.

       

      2. In my script creating the new page, still opening each of the other 4 documents as a copy, I've tried grouping allPageItems/pageItems but this will throw an error saying "invalid parameter" sometimes when creating the new group. After researching this, it appears it happens when I've got an object of type EPS or PDF, or something other than textframes and rectangles, and cannot be grouped. I'm still not sure on this one because I haven't seen it defined anywhere what objects can and can't be grouped. The goal of this is to create the group, duplicate it onto my new page, and move it to where it needs to be, thus copying all content onto my new page. Is there a property of a pageItem that let's you know if it can be grouped or not?

       

      Is there a way I can successfully group all page items for any scenario of objects?

       

      Or maybe is there a better way to copy the page or all of it's contents onto a new page?

       

      EDIT: Another option would be to embed the smaller documents into my new document. The reason I can't place them is because they get placed as graphics which link out to the original documents and I need the interactive content of that document to be carried through to the new one. Does anyone know if it is possible to embed documents or a better way to copy content through while preserving interactive content?

       

      Many thanks in advance!

       

      -Lloyd

       

      Message was edited by: lhanneman

       

      Message was edited by: lhanneman

        • 1. Re: Copy all page items into new document - Invalid parameter? [CS5][JS]
          Manan Joshi Level 4

          What you could do is open each document, copy the pageitems on it spread wise, because you won't be able to select pageitems on different spreads. Then paste these pageitems onto your new document. If you want you can also preserve the layers on which the pageitems were placed on the original document while pasting the pageitems on the destination document.

           

          Hope this helps your cause.

           

          Manan Joshi

           

          - Efficient InDesign Solutions

          -MetaDesign Solutions

          http://metadesignsolutions.com/services/indesign-development.php

          • 2. Re: Copy all page items into new document - Invalid parameter? [CS5][JS]
            lhanneman Level 1

            Thanks for the reply! Looking through the CS5 JS object reference guide, I'm not seeing  how you'd copy and paste pageItems. Unless you're talking about the duplicate() function, which I've already tried. I can't copy & paste pageItems individually I don't think, because the ultimate goal is to have all of the content on a page placed onto a new page at specific coordinates (as if the page were placed on the new page). That's why I was hoping to group all of the pageItems and then duplicate that group onto my new page, and then move that group to the coordinates I need.

             

            Hopefully that makes sense.

            • 3. Re: Copy all page items into new document - Invalid parameter? [CS5][JS]
              Manan Joshi Level 4

              iterate through the spreads of the source documents as i explained before, then for each spread traverse the paeitems on that spread and add them to the selection with the statement

               

              pageitem.select(SelectionOptions.ADD_TO);

               

              once all the items of a spread are selected use

               

              app.copy()

               

              then change over to the destination document i.e. make the destination doc as the active document and then use

               

              app.paste()

               

              repeat this process for every spread in the document, and remember to remove the selection before moving on to selecting the page items on the next spread.

               

              Hope this clears what i am trying to explain and it solves your issue.

               

              Manan Joshi

               

              - Efficient InDesign Solutions

              -MetaDesign Solutions

              http://metadesignsolutions.com/services/indesign-development.php

              • 4. Re: Copy all page items into new document - Invalid parameter? [CS5][JS]
                lhanneman Level 1

                Two concerns:

                 

                1. I've always tried avoiding using application settings/functions (i.e. app.copy()) because our scripts will be run on InDesign server and I'm not sure if wires can get crossed if multiple scripts are running at once). Are you familiar with how that would work on InDesign server? We've got one server with multiple instances, but I'm not sure if "application" is shared across instances or not?

                 

                2. After I call app.paste() how can I move all of those page items (as a group) to one specific set of coordinates? Can I call a move function on the current selection similar to Group.move? I need the end result to be as if I placed page 1 of document A onto page 1 of document B at coordinates (X,Y). Page 1 of document B will be smaller, and able to fit completely onto page 1 of Document A, but I obviously can't place a page onto another page, which is why I'm just trying to copy content over as I've explained.

                 

                Thoughts?

                 

                And thank you again!

                • 5. Re: Copy all page items into new document - Invalid parameter? [CS5][JS]
                  Manan Joshi Level 4

                  For the first point i am not sure if you will indeed run into any issues, we never got into any problems using application level methods on the IDS. However you will have to try and create a case where you think this might create a problem and share your observations here for the benefit of others too:)

                   

                  And for the second point you could maybe try the app.pasteInPlace() method rather than app.paste() and see if it works for you. Anyhow how are you creating the group that you are failing in some cases. Give the code so that i can see if i can figure out something that might be missing from your eyes....

                   

                  Thanks

                  -Manan

                  • 6. Re: Copy all page items into new document - Invalid parameter? [CS5][JS]
                    lhanneman Level 1

                    Thank you, if we go that route with app.copy() and app.paste() I'll definitely post any issues I come across.

                     

                    For the code that wasn't working for me before - I may have actually just found a solution for that. It appears to actually work groupiing page.pageItems if I make sure that none of the pageItems are locked beforehand. So right now I'm looping through pageItems, and unlocking each item as I go, putting them into a new array. From that array I can group the items successfully.

                     

                    If this continues to work the way I need it to, I'll likely go with this solution.