4

I would like to merge 4 pdfs, pdf1.pdf, pdf2.pdf, pdf3.pdf pdf4.pdf together so that the pdfs are spliced, i.e. the first page will be the first page of pdf1, the second the first of pdf2, the third the first of pdf3, etc.

The pdf files are with plain images, no table of contents.

How would I accomplish this? It would be nice to do it from Terminal as well.

  • 3
    Possible duplicate of Merging PDF files Together – Edd Growl May 20 at 15:45
  • Welcome to ASE, Michael. @EddGrowl I dont think so. It will need apple script. Although the question linked can be helpful for scripting. – ankiiiiiii May 20 at 15:47
  • Do all all the PDF files have the same page count? Do any of the PDF file have a Table of Contents, or are then just plain PDF files with plain pages? – user3439894 May 20 at 15:58
  • they are just pdf files with plain images, no table of contents. – Michael Klyachman May 20 at 16:32
  • 1
    @Michael Klyachman, I've removed "Solved using the PyPDF2 module." from the question as answers belong in their own answer, not the question. Feel free to post your own answer, which you can even accept as the accepted answer for you, and thus increasing your reputation points. – user3439894 May 20 at 18:49
5

This can be done using a macOS default built-in, from either the command line or its GUI app the action belongs to.

To do as you requested from the command line, in Terminal, use the following command example:

"/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py" --shuffle -o /path/to/collated.pdf /path/to/file1.pdf /path/to/file2.pdf /path/to/file3.pdf /path/to/file4.pdf

To make the macOS built-in join.py script easier to use from the command line, I'd suggest you make a symbolic link for it. As an example, if you have /usr/local/bin in your PATH:

sudo ln -s "/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py" "/usr/local/bin/pdfjoin"

Afterwards, you can start the command with just pdfjoin instead of using its fully qualified pathname.


Below is a image of an Automator workflow to show an example of how it can be achieved using a macOS default built-in GUI app. Note that it can be modified many different ways to suit one's needs/wants.

enter image description here

Note: The Combine PDF Pages action, when used in Automator creates a temp file and why additional actions are needed to refine the workflow. You could just use the Open Finder Items action directly after and forgo the other actions, but of course you'll need to then manually save the opened new pdf file elsewhere.

1

I do this in preview:

Open the first one,

Select the others,

With the sidebar « thumbnails » visible, just drag and drop into the sidebar.

Check order but usually they go in by name order...

How I create my exams...

Each one is one page, created in excel with headers and page numbers exported as pdf...

  • this does not work, as it just puts the pdfs next to each other. I need it to go 1_1 1_2 1_3 1_4 2_1 2_2 2_3 2_4, where a_n represents the a-th page of pdf number n. – Michael Klyachman May 20 at 16:31
  • Don't know what you are doing - just done one exam with 7 pages, started with cover page and dropped the others in... works fine for me. You can drop 1 in at a time if you wish... – Solar Mike May 20 at 16:36
  • dropping in 1 at a time is inefficient when dealing with a several-hundred-page pdf. I solved this using the PyPDF2 module. – Michael Klyachman May 20 at 16:49
  • You did state 4 pdf's in your question, or did you mean 400? – Solar Mike May 20 at 16:51
  • I meant 4 pdfs, each of which is several hundred pages long. Sorry if it came across differently. – Michael Klyachman May 20 at 16:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .