1 Reply Latest reply on May 29, 2013 6:47 PM by milligramme

    Trying to scale a pdf page when placing into a document

    stewa52 Level 1

      I am trying to scale a pdf page to fit the document when placing in the document.

       

      Currently, I am calling:

      myPage.place(File(myPDFFile), [0,0])[0];

       

      How would I enlarge the pdf to fit the containing indesign page?

        • 1. Re: Trying to scale a pdf page when placing into a document
          milligramme Level 3

          Hi

          try this code

           

          #target "InDesign"
          
          var doc  = app.documents[0];
          var doc_pref = doc.documentPreferences;
          
          
          var pdf = doc.pages[0].place(File("/path/to/pdf.pdf"));
          
          // get pdf-container
          var rect = pdf[0].parent;
          rect.geometricBounds = [0,0,doc_pref.pageHeight, doc_pref.pageWidth];
          
          // fit
          rect.fit(FitOptions.PROPORTIONALLY);// or other option
          
          

           

          or create a rectangle first and then place and fit.

           

           

          var rect = doc.pages[0].rectangles.add({
            geometricBounds: [0,0,doc_pref.pageHeight, doc_pref.pageWidth],
            strokeWeight: 0,
            strokeColor: "None"
          });
          rect.place(File("/path/to/pdf.pdf"));
          rect.fit(FitOptions.PROPORTIONALLY);
          
          

           

          thanks

          mg