3 Replies Latest reply on Mar 3, 2017 9:12 AM by arekh2792424

    relink pages of a PDF file

    laindustria

      Hi, I'm trying to relink the artworks of an illustrator file (I suppose is the same used with the PDF files).

      I have seen codes like the multi page placer, importer or so. and I cannt find find my answer.

      I have learned to import the pages or artworks using the place method preceded by the app.pdfPlacePreferences.pageNumber line to set the page desired.

      but that way takes too long for the amount of images I'm working with.

      Then I have learned to relink the pages using the relink method. It is 2+ faster, but it just updates the link with the pages in the position used at the beginning. I want for example to relink with the page x in place of the page y and so, e.g, in another order.

      Thanks for any help.

        • 1. Re: relink pages of a PDF file
          Jump_Over Level 5

          Hi,

           

          That's why relink is faster perhaps?

          You need to set app.pdfPlacePreferences.pageNumber to reach a proper page, right?

          Method place(File) has a parameter "showOptions" which means it has to read a set of app and doc preferences before executing and take care about their values.

          Method relink(File) doesn't care probably...

           

          I am not sure, guessing only...

           

          Jarek

          • 2. Re: relink pages of a PDF file
            laindustria Level 1

            I think I'll start to lose hope, unless I find another way.

            Thanks Jarek.

            • 3. Re: relink pages of a PDF file
              arekh2792424 Level 1

              Hello! I encountered a similar problem and my solution may be of value to you.

               

              This is how I broke it down:

               

              1: Create a dialog with an edit box where you type the number of pages in the document you wish to import.

              2: Prompt the user to select a file to place.

              3: Create a for loop that iterates through as many times as there are pages in the placed PDF

              4: Import the page number of the PDF on the matching page number on the indesign file by refering to the current value of the counter for both.

               

               

               

              Here are some segments of code from my script that may be of use to you:

                 

              1: with(borderPanels.add()){

                                  staticTexts.add({staticLabel: "Page Count:"});

                                  var PageCount = integerEditboxes.add({minimumValue: 1, maximumValue: 9999, editValue: 1, minWidth: 50});

                                  }

              var SelectedPageCount = parseInt(PageCount.editValue);

               

              2: var Art = File.openDialog

               

              3/4: function PlaceFile (Document, Art, SelectedPageCount) {

                  //Create a counter from the page count

                  var Counter = SelectedPageCount

                 

                      // Automated Placement

                           for (Counter; Counter > 0; Counter --) {

                                  app.pdfPlacePreferences.pageNumber = Counter;

                                  var placeFile1 = Document.pages.item(Counter + "").place(Art, ["0.5in" ,"0.5in"])[0];

                                  //This resets the imported page default to 1 for next time a document is placed

                                  app.pdfPlacePreferences.pageNumber = 1;

                               }

                          }

               

               

              I hope this is of use to you! Perhaps you could use this theory with some tweaks for specific pages only using a dialog etc?