Combine Selected PDF Files

It seems like such a simple thing, but in fact, can be very tricky to accomplish by hand: combining multiple PDF documents into a single PDF document. However, the good news is that you can create an Automator workflow service that makes the process a one-click operation.

The following documentation describes an Automator workflow for creating a new PDF document containing the merged contents of multiple PDF documents.

The Service Workflow

DO THIS ►Launch Automator and create a new service workflow. Leaving the document unsaved, replicate the workflow described in detail below.

 1  Data Input Bar  (⬇ see below )  • The first step in creating any Automator service is to set the parameters of the data input bar at the top of the workflow document window. Set the input data type by selecting “PDF files” from the input types popup menu  1 , and then select the Finder application from the target application  2  popup menu.

 2  Combine PDF Pages • Locate and add this action from the PDF category of the Automator action library. There is a single parameter for indicating whether the pages of the input PDF files should be joined by appending them to each other {A, B, C}, {D, E, F}, {G, H, I} = {A, B, C, D, E, F, G, H, I}, or if the pages should be shuffled incrementally from each of the documents {A, B, C}, {D, E, F}, {G, H, I} = {A, D, G, B, E, H, C, F, I}.

 3  Set Value of Variable • Locate and add this action from the Utilities category of the Automator action library. Select New variable… from the popup menu  4  to create and name a new variable for storing a reference to the new PDF file created by the previous action.

pdf-combine-wkflw-01

 4  Ask for Text  (⬆ see above )  • Locate and add this action from the Text category of the Automator action library. When run, this action will display a dialog containing a message and a text entry field. Enter a prompt for the service user in the provided text field  5 , to provide a name for the created file. In the text field below  6 , enter a default name for the file, something like: Combined PDF Files. Make sure that the checkbox for requiring the user to provide input in the dialog  7 , is selected. NOTE: click the Options button in the action view  8 , and select the checkbox option for ignoring input from the previous action.

 5  Set Value of Variable • Locate and add this action from the Utilities category of the Automator action library. Select New variable… from the popup menu  9  to create and name a new variable for storing the file name entered by the user in the previous action.

 6  Get Value of Variable  (⬇ see below )  • Locate and add this action from the Utilities category of the Automator action library. This action will retrieve data stored earlier in the workflow. From the popup menu  1  select the name of the variable you created to store the reference of the created PDF file. NOTE: click the Options button in the action view  2 , and select the checkbox option for ignoring input from the previous action.

 7  Rename Finder Items • Locate and add this action from the Files & Folders category of the Automator action library. This action will be used to name the created PDF file to the name the user provided earlier in the workflow. Select Name Single Item from the renaming method popup menu  3 , and Basename only from the naming scope popup menu  4 .

Next, click the Variable List Display control at the bottom of the workflow window  5  to show a list of all workflow variables, and drag the variable you created to store the user-provided file name  6  to the replacement text input field  7  in the action view. The contents of the variable will be used to name the created PDF combination file.

pdf-combine-wkflw-02

 8  Move Finder Items  (⬆ see above )  • Locate and add this action from the Files & Folders category of the Automator action library. This action will move the created PDF file to the location you indicated in the destination popup menu  8 . To avoid naming conflicts, enable the checkbox for replacing existing files  9 .

 9  Open Finder Items • Locate and add this action from the Files & Folders category of the Automator action library. This action will open the created PDF file in the application chosen from the application popup menu  10 .

Save the Service

To save and install the service, select Save from the Automator File menu and enter the name for the service in the forthcoming sheet.  (⬇ see below ) 

save-sheet

NOTE: The name you assign for the workflow file will be the menu title that appears in the Services and contextual menus.

Using the Service

With the service created and installed, you are now ready to try it out. We’ve provided some example files for this purpose.

DO THIS ►DOWNLOAD and unpack a ZIP archive (2.4 MB) of PDF files from the U.S. Census Bureau.

Unpacking the archive will create a folder containing six multiple-page PDF files  (⬇ see below ) . Each PDF file contains information about voting registration trends for one of the previous six United States Federal elections (U.S. Census: Voting and Registration). You will use the service to combine these six files into a single PDF file.

DO THIS ►With all of the files in the folder selected  1 , click the Action Menu popup  2  to summon the contextual menu. Select the service from the bottom section of the menu  3 .

contextual-menu

The workflow will execute, combining the selected PDF files into a single new PDF file, and then prompt for the user to enter a name for the new file  (⬇ see below )  :

name-prompt-01

DO THIS ►In the prompt dialog, enter a name for the created PDF file  (⬇ see below )  :

name-prompt-02

The created file will be named, moved to the Desktop, and opened in Preview  (⬇ see below )  :

combined-pdf-preview
Download & Install the Service

For your connivence, we’ve provided the completed Automator workflow service for you to download and install. Follow the directions below:

DO THIS ► DOWNLOAD the example Automator service workflow file.

The Automator service workflow file appear when the ZIP archive is uncompressed.  (⬇ see below ) 

Automator-Document-256

Standard installation of an Automator service is usually accomplished by double-clicking the workflow file in the Finder. However, doing so may summon the following security dialog:

cannot-open-dialog

This occurs because Automator workflow files are currently saved without a developer signature, and the GateKeeper security settings in the Privacy system preference on your computer are set (by default) to only allow developer-signed workflow files be opened.  (⬇ see below ) 

gatekeeper-settings

Fortunately, OS X provides a mechanism for knowingly opening a quarantined workflow file.

DO THIS ►Right-click on the workflow file in the Finder to summon the Finder’s contextual menu. Choose Open from this menu:  (⬇ see below ) 

contextual-menu-open

A second security dialog appears, but contains an option for opening the workflow file.  (⬇ see below ) 

open-confirmation-dialog

DO THIS ►Click the Open button in the security dialog.  (⬆ see above ) 

Now that you’ve approved the workflow file for opening, the standard service workflow installation process will begin with the presentation of the Service Installer dialog.  (⬇ see below ) 

service-install-dialog-01

DO THIS ►To installer the Automator service, click the Install button in the Service Installer dialog.  (⬆ see above ) 

The workflow service will be installed in the Services folder in your user Library folder, and a completion notification dialog will offer the view the installed service in Automator.  (⬇ see below ) 

service-install-dialog-03

TOP