2 Replies Latest reply on Jan 23, 2013 9:33 AM by Jump_Over

    [JS] [CS5] Copy and paste into existing array

    Statixx91

      Hi Guys,

       

       

      right now I'm trying to improve the performance of a Script I wrote by copying and pasting a PDF instead of loading it 10 times.

       

      And here's the problem:

      When pasting the copied PDF it doesn't paste it into the array the original PDF is in but this is exactly what I need for the further script.

      Can I somehow paste the PDF into the Array and a specific position [i]?

       

      I'm adding the important parts of the script.

       

      Greetings Michael

       

      var myDocument = app.activeDocument;

      var myPage = myDocument.pages.item(0);

       

      var myPageHeight = myDocument.documentPreferences.pageHeight;

      var myPageWidth = myDocument.documentPreferences.pageWidth;

       

      myVertical=new Array();

       

      var myVerticalCount=0;

       

      var myStrokeHeight = myVertical[0].geometricBounds[2]-myVertical[0].geometricBounds[0];

      var myStrokeWidth = myVertical[0].geometricBounds[3]-myVertical[0].geometricBounds[1];

       

      for(i = 0; (myPageWidth-(i*myStrokeWidth))/(i+1) > (myStrokeWidth/3);i++){

                              myHorizontalCount++;

                          }

                     

      myVertical[0] = myPage.rectangles.add({geometricBounds:[myPageHeight/2,0,myPageHeight +3,3]});

      myVertical[0].place (File(myFile_Vert));

      myVertical[0].strokeWeight = 0;

      myVertical[0].fit (FitOptions.FRAME_TO_CONTENT);

       

       

      app.select (null);

                        

                          //It should be pasted into the Array myVertical[i]

       

                          app.select (myVertical[0]);

                          app.copy ();

                         

                          for(i=1;i<myVerticalCount;i++)

                              {

                                  app.paste();               //into myVertical[i] somehow

                              }