You may have encountered the following situation: You have done multiple screen captures under Mac OS and you want to combine them into one PDF file without too much manual work. Here is what I did using the Mac OS Terminal and hope it will help you if you are in a similar situation. This solution has its advantage when you have a lot of files to process. It is much easier than the dragging and dropping method done in Preview.

There is/are one or two steps involved depending on if your default screen capture is in an image format or PDF format. If your default setting is in PDF format, you can skip Step 1.

Step 1: Convert image files to PDF files.

If like me, your default screen capture is in an image format, such as .png, you need to change each .png file to PDF file first. You can tweak the code a little bit if the images are in a different format, for instance, .jpg.

  • Make sure you have sips (scriptable image processing system), which comes with Mac OS 10.4 or later, on your computer. Type sips –h , you should see something similar to the image below if you have sips.sips
  • Put all the image files in a folder. Using the command line to go to that folder. Now you will need to do a batch processing use sips (note: before “out” there are two short “-“s, the display may show this as a long dash):
    for i in *.png; do sips -s format pdf $i –out $i.pdf; done
  • You can double check your folder to make sure everything is done right. Your file names may look like image1.png.pdf, which is OK and you do not need to change the file names.

Step 2: Merge PDF files into one PDF file

  • From Tiger onwards, Mac OS comes with a Python script that allows you to combine PDF files. Here is what you type or copy into the Terminal window. The combined file is named merged.pdf. Following that, you provide either a directory/folder for processing or list the individual PDF file directory and name. For me, all the PDF files waiting to be combined are in a folder named pdfs and the merged.pdf will be under the same directory as the pdfs
    “/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py” -o merged.pdf pdfs/*.pdf

That’s it. You are done. Check the file named merged.pdf to make sure everything is alright.

Advertisements