3 Replies Latest reply on Oct 12, 2014 11:35 AM by CarlosCanto

    How to "Place as linked file" (not "import") a multipage PDF file on a single Artboard ?

    Bob Charlos

      ILLUSTRATOR CS4

       

      Hello,

       

      I often use the import multiPDF script from Carlos Santo and it works great.

      But i sometimes get multipage PDFs from customers only with text, and the fonts are so rarely embedded.

      As you may know, the solution to have this fonts "vectorised" even if you don't have it in your Font collection is to place your pdf as linked file (menu File-> Place with the "link" box checked) in an open document (or to drag and drop it), and then, via the Menu Object->Flatten Transparency, i check the box "Embed text" to have it done.

       

      So to automate it with a multipage PDF, and inspired by Carlos' script, I tried this :

       

      /////////////////////////////////////////////////

      var doc = app.activeDocument;

      app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

       

      var pdfOptions = app.preferences.PDFFileOptions;

       

      var firstPage = 1;

      var lastPage = 10;

       

      pdfFile = File.openDialog("Open Multi-page PDF", "*.pdf", false);

       

      for (i= firstPage;i<lastPage;i++)

           {

               pdfOptions.pageToOpen = i;

               var  thisPlacedItem = doc.placedItems.add();

               thisPlacedItem.file = pdfFile;

           };

      /////////////////////////////////////////////////

       

      It doesn't work ! I end up with 10 placedItems of the page number 1 of the pdf file. Maybe that the pageToOpen option only works when i use the Open method ? In fact no, cause if i launch only the following 2 lines and then i drag and drop the pdf file, the page specified (page 8 in the example) is right placed.

       

      //////////////////

      var pdfOptions = app.preferences.PDFFileOptions;

      pdfOptions.pageToOpen = 8;

      /////////////////

       

      I don't know how to do to fix it. I have 2 solutions but it only makes it "semi automatic" :

       

      - Create a palette dialog with a button than increases one by one the pageToOpen option and then drag and drop my file one time for every pages (easy)

       

      - Without the palette and the button, but with an event listener with a function that increases the pageToOpen value each time i drag and drop a new file (maybe by listening to changes in document.placedItems.length), but is it possible ?

       

      Any suggestions ?

       

      Thank you for your help!

        • 1. Re: How to "Place as linked file" (not "import") a multipage PDF file on a single Artboard ?
          CarlosCanto Adobe Community Professional & MVP

          I end up with 10 placedItems of the page number 1 of the pdf file. Maybe that the pageToOpenoption only works when i use the Open method ?

          I had the same problem, my first option was to place the pdf pages, I couldn't make it work so I had no choice but to open the file instead.

           

          going with your first option, besides dragging, Actions can also place the correct page, based on the pageToOpen property...so there's hope, record an Action to place your pdf and...

          1. run your script to increase the pageToOpen property

          2. play your action

          3. repeat for each page

           

          actions can also run scripts, so you can do that too.

           

          if you had CS6, it'd be easier, CS6 can play Actions with Javascript

          • 2. Re: How to "Place as linked file" (not "import") a multipage PDF file on a single Artboard ?
            Bob Charlos Level 1

            Ok,

             

            So I just have to record an action to place the file, and then insert my script. Thats a good solution and it's very

            timesaving to use it !

             

            The script increases the pagetoopen option, but i also added a palette with a button to reset the counter and another button to increase it by yourself, in case if i just wanted to place page 3, page 8 for example.

             

            Thank you for your help !

             

             

             

            //////////////////////////////

            #target illustrator

            #targetengine session

             

            var doc = app.activeDocument;

            var pdfOptions = app.preferences.PDFFileOptions;

             

            var win = new Window ("palette");

            win.location = [50, 500];

            var btnReset = win.add("button",undefined,"reset");

            var btnInc = win.add("button",undefined,"+1");

            var txtcpt = win.add("statictext",undefined,"Page number : " + pdfOptions.pageToOpen);

             

            btnInc.onClick = function()

            {

                pdfOptions.pageToOpen++;

                txtcpt.text = "Page number : " + pdfOptions.pageToOpen;

            }

             

            btnReset.onClick = function()

            {

                pdfOptions.pageToOpen = 1;

                txtcpt.text = "Page number : " + pdfOptions.pageToOpen;

            }

            win.show();

             

            pdfOptions.pageToOpen++;

             

            ///////////////////////////////////////////////////