4 Replies Latest reply on Dec 20, 2013 12:31 PM by elDudereno

    How to merge the pdf files into single pdf?

    Maria prabhudoss Level 1

      I need to merge the two (or) three pdf files into a single pdf via scripting. I used the below code for inserting(merging) the pages.

       

      this.insertPages({cPath: "Test.pdf"})

       

      But its merginging(inserting) successfully. But the links not working after inserting. kindly advise me the solution or any other ways.

       

      I am using Acrobat 8.0.

       

      Thanks in advance..

        • 1. Re: How to merge the pdf files into single pdf?
          Bernd Alheit Adobe Community Professional & MVP

          Write a plugin for Acrobat. In a plugin you can combine the files and change the links.

          • 2. Re: How to merge the pdf files into single pdf?
            Maria prabhudoss Level 1

            Is it possible via scripting(javascript\vbscript)?

            • 4. Re: How to merge the pdf files into single pdf?
              elDudereno Level 3

              http://gotofritz.net/blog/howto/joining-pdf-files-in-os-x-from-the-command-line/   <- this works but it strips OPI

               

              Here's what I did: (This is shell script)

               

              #!/bin/bash
              FROM="./"
              DESTINATION="./unCombined/"
              for i in $(ls *_F_ga.pdf)
                        do
                        BACK=`echo "$i" | sed "s/_F_/_B_/g"`
                        if [ -f $BACK ] ; then
                                  open "$i"
                                  osascript selectMenuItem.scpt
                                  sleep 3
                                  mv -f "$FROM/$i" $DESTINATION
                                  mv -f "$FROM/$BACK" $DESTINATION
                        fi
              done
              
              

               

              This calls an applescript

               

              tell application "/Applications/Adobe Acrobat X Pro/Adobe Acrobat Pro.app"
               activate
              end tell
              
              tell application "System Events"
                        tell process "Acrobat"
                                  click menu item "combine Front and Back" of menu "File" of menu bar 1
                        end tell
              end tell
              
              

               

              Which activates a menu item (made with Java and saved into Macintosh\ HD/Users/*user*/Library/Application\ Support/Adobe/Acrobat/10.0/JavaScripts)

               

              app.addMenuItem({
                  cName: "combineFB",
                  cUser: "combine Front and Back",
                  cParent: "File",
                  cExec: "combineFrontAndBack()",
                  nPos: 0
              });
              
              

               

              Which activates this script (again saved into Macintosh\ HD/Users/*user*/Library/Application\ Support/Adobe/Acrobat/10.0/JavaScripts)

               

               

              combineFrontAndBack = app.trustedFunction(
              function(){
              // get the file name and extension
              var sFullFileName =  this.documentFileName
              // make into an arry
              var aFullFileName = sFullFileName.split('_F_');
              // build a file name array dropping the extension
              var aFileName = new Array(aFullFileName.length - 2);
              for (i = 0; i < aFullFileName.length - 1; i++) {
              aFileName[i] = aFullFileName[i];
              }
              // recreate file name
              var sFileName = aFileName.join('.');
              var back = sFileName + "_B_ga.pdf";
              app.beginPriv(); // Explicitly raise privilege
              //add back page based on front page name
              this.insertPages ({
                                  nPage: 0,
                                  cPath: "/Macintosh HD/Users/jfox/test/" + back,
                                  nStart: 0
                        });
              this.saveAs("/Macintosh HD/Users/jfox/test/" + sFileName + "_ga.pdf");
              this.closeDoc(true);
              app.endPriv();
              return true;
              }
              );
              
              

               

              It's convoluted and comparitively slow, but it works.

               

               

              EDIT: I just realized you probably meant document links and not OPI links. Ha ha. I have no Idea what this would do to document links.