3 Replies Latest reply on Jan 28, 2010 12:09 PM by Kathlene Ruhan

    Multipages pdf place in ractangel frame

    2008Mac

      Hi All

       

      Is there any work around this that i want to import x PDF file in rectangels instead of pages.

      I tried with given code but it's place first page repeatedly in all rectangels.

       

      main();
      function main(){
      //var myCounter = 1;
      var myDocument = app.documents.item(0);
      var myPage = myDocument.pages.item(0);
      var myPDFFile = File.openDialog("Choose a PDF File");
      var myRectangles = myDocument.rectangles.everyItem();
      if((myPDFFile != null)){
      myPlacePDF(myDocument, myRectangles, myPDFFile);
      }

      function myPlacePDF(myDocument, myRectangles, myPDFFile){
      var myPDFPage;
      //app.pdfPlacePreferences.pdfCrop = PDFCrop.cropMedia;
      var myCounter = 1;
      var myBreak = false;
      while(myBreak == false){
        if(myCounter > 1){
         myPage = myDocument.pages.add(LocationOptions.after, myPage);
        }
        app.pdfPlacePreferences.pageNumber = myCounter;
        myPDFPage = myRectangles.place(File(myPDFFile), false)[0];

        if(myCounter == 1){
         var myFirstPage = myPDFPage.pdfAttributes.pageNumber;
        }
        else{
         if(myPDFPage.pdfAttributes.pageNumber == myFirstPage){
          myPage.remove();
          myBreak = true;
         }
        }
        myCounter = myCounter + 1;
      }
      }
      }

       

       

       

      Many Thanks in advance

      Subhendu

        • 1. Re: Multipages pdf place in ractangel frame
          ramkumar.vp Level 3

          Hi Subhendu,


          in your script variable "myPDFPage" is getting a array.


          So you can use  var myFirstPage = myPDFPage[0].pdfAttributes.pageNumber;


          And also "myRectangles" is collection of all Rectangles. If you use the for loop to place PDF (page by page) then only it place the pdfs sequentially.


          Regards,

          Ramkumar .P

          • 2. Re: Multipages pdf place in ractangel frame
            Shonkyin Level 3

            Hi Subhendu,

             

            Please check below code:

             

            main();

            function main(){

            //var myCounter = 1;

            var myDocument = app.documents.item(0);

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

            var myPDFFile = File.openDialog("Choose a PDF File");

            var myRectangles = myDocument.rectangles.everyItem();

            if((myPDFFile != null)){

            myPlacePDF(myDocument, myRectangles, myPDFFile);

            }

            function myPlacePDF(myDocument, myRectangles, myPDFFile){

            var myPDFPage;

            //app.pdfPlacePreferences.pdfCrop = PDFCrop.cropMedia;

            var myCounter = 1;

            for (a=myDocument.rectangles.length-1; a>=0; a--)

            {

            app.pdfPlacePreferences.pageNumber = myCounter;

            myDocument.rectangles[a].place(File(myPDFFile), false)[0]

            myCounter = myCounter + 1;

            }

            }

             

            Thanks,

            Shonky

            • 3. Re: Multipages pdf place in ractangel frame
              Kathlene Ruhan Level 3

              What program are you placing these images into?