3 Replies Latest reply on Jul 30, 2018 8:27 PM by O2 Creative NZ

    Get the Place PDF dialog to select different page for linked file

    antons23464226

      Hi all,

       

      I have a multipage PDF that is linked in AI. I've imported Page 1, and I used Transform to achieve a Step and Repeat pattern.

      After expanding and ungrouping I have a let's say 10 x 10 grid of that first page.

      I need to go through each of these 100 positions and relink to a different (random) page from that same initially linked PDF.

      What i'd like is a script upon which execution I'd get the Place PDF dialog, using the same already linked file, and skipping the Relink dialog.

       

      So far I've automated this via an action, but I have to rerecord it each time for different incoming PDF file.

       

      The functionality I need is exactly the same as this line of code:

      1. var g; (g=app.selection[0].graphics[0]). 
      2.     place(g.itemLink.filePath, true); 

      which does the trick for InDesign. Of course, the AI JS syntax is different

       

      I'm very new to scripting and I'd appreciate any help.

       

      Thanks in advance!

        • 1. Re: Get the Place PDF dialog to select different page for linked file
          williamadowling Level 4

          If there's some functionality available in InDesign, it's a relatively safe bet to assume you can't do it in illustrator...

           

          Now, i'm being facetious.. sort of. Unfortunately Adobe does not seem to care very much about whether we have the support we need.

           

          That said, i have not tried placing images with JS in AI yet. let me poke around and see what i can find.

          • 2. Re: Get the Place PDF dialog to select different page for linked file
            Silly-V Adobe Community Professional

            I'm having this awesome issue which I tried to solve with this method, but my search goes on. However it got me to re-visit this question and I put to the test what I read somewhere sometime ago: doing the preferences PDF open options affects the next placed item's file's target placing page!

             

            var doc = app.activeDocument;

            var fileToPlace = File("~/Desktop/test.ai");

             

             

            for (var i = 3; i < 6; i++) {

            var openOpts = app.preferences.PDFFileOptions;

            openOpts.pageToOpen = i;

            var placed = doc.placedItems.add();

            placed.file = fileToPlace;

            }

            • 3. Re: Get the Place PDF dialog to select different page for linked file
              O2 Creative NZ Level 2

              Hi

               

              You can import specific pages at specified scale + crop boxes by creating a temp AI file, I did this for my multipage PDF importer PowerScript.

               

              What I do is write a basic AI file in text format linking to the PDF, with as many pages as I need, all the pages are just centered on the page using a basic transform matrix, then open the file, copy/Paste the page contents to the current document, then close and delete the temp file.

               

              Hardest part is finding the number of pages in the PDF file before opening it.