78

How can I convert about 100 PNGs to one PDF on a Mac? I'm open to using the command line if it helps.

I have tried using iPhoto, but it quits, not sure why. Saving from Preview doesn't quite do what I want. Thoughts?

tekknolagi
  • 1,370
  • 3
  • 15
  • 34
  • Duplicate question on AskDifferent: https://apple.stackexchange.com/questions/11163/how-do-i-combine-two-or-more-images-to-get-a-single-pdf-file – tir38 Jan 03 '18 at 21:54

7 Answers7

95

If you have Leopard (10.5 or later) or Lion the easiest way is to use Preview. Just do the following:

  1. Open the first image in Preview
  2. Show the the sidebar (Shift-Command-D)
  3. Drag any additional images to the sidebar
  4. Go to File > Print (Command P)
  5. In the PDF dropdown list select Save as PDF

That's it! You should now have a PDF containing all your images.

If that doesn't work for you, you should look at any third-party solutions such as Adobe Acrobat Pro which has a combine feature or PDFLab.

1.21 gigawatts
  • 2,064
  • 7
  • 33
  • 51
mekwall
  • 1,898
  • 1
  • 16
  • 13
  • 1
    +1 - My suggested solution as well. I've used this method to combine several PDFs by printing, then choosing "Save as PDF" from the print panel. – SplinterReality Oct 25 '11 at 07:59
  • 4
    For me in Snow Leopard, File > Print only printed the first image. I had to select File > Print Selected Images in order to print all of them. – kldavis4 Jul 23 '14 at 21:09
  • 4
    Shift-Cmd-D didn't open sidebar for me, I had to explicitly use View -> Thumbnails (option - Cmd - 2) - on mac os x el capitan v10.11.3 - otherwise the instructions worked a charm. – arcseldon Feb 22 '16 at 03:58
  • It's 2018 and this method still works like charm. Thanks for this answer. – Lucio Mollinedo Jun 12 '18 at 16:27
  • unfortunatelly this method will not save rotation if it different across images – CAMOBAP Apr 13 '21 at 07:42
  • not having a printer does not allow me to hit print and save the pdf – Coding Edgar Apr 28 '21 at 15:21
  • OP stated: to be open to use command line if it helps, has 100 files, saving from Preview doesn't quite do what I want. It makes no sense that this is the accepted answer. The answer that `kqw` presents ticks all boxes. – nilon Jun 15 '21 at 15:41
  • doesnt seem to work anymore – David 天宇 Wong Dec 12 '22 at 22:47
77

I prefer using command line tools such as ImageMagick for this type of work. You can install IM with Homebrew:

brew install imagemagick

Afterwards you can do

convert *.jpg output.pdf

and if the resulting PDF is a bit too big you can try:

convert -quality 60 *.jpg output.pdf

Of course ImageMagick also works on other Unix systems, and even on cygwin.

(If you want a specific order you can also write out the .jpg filenames one by one. Or use * and rename the .jpgs in alphabetical order.)

the
  • 2,751
  • 1
  • 26
  • 35
  • after running this command, every image that *.jpg expanded to was overwritten with the first image, and only the final one was saved to PDF – user5359531 Nov 01 '16 at 18:25
  • @user5359531 Strange. For me this has worked perfectly many times before and to double check I just tried it again. No problem. What was the exact command you ran? And which version? `convert --version|head -1` gives me `Version: ImageMagick 6.9.5-2 Q16 x86_64 2016-07-13 http://www.imagemagick.org` – the Nov 01 '16 at 22:48
  • how do you order the pages? – JohnnyQ Jan 19 '17 at 13:43
  • 2
    @JohnnyQ Name the image files in the order that you want the pages to appear in the PDF. – coredumperror Jan 23 '17 at 20:25
  • 2
    This. It works beautifully, for any aspect ratio - the Print answer above is more of a hack than anything else. – Vlad Apr 03 '18 at 14:28
  • 2
    this is the best answer for me – papashou Apr 11 '18 at 09:08
  • Works beautifully for the use case I just ran employing `ImageMagick 7.1.0-17` on `macOS 10.14.6 buildversion 18G9323`. – Johnny Utahh Dec 14 '21 at 04:43
11

My method is similar to Marcus's, but works a little better for me when the images are all different sizes and you don't want the PDF to just be all 8.5x11 but to keep each page the size of the original image.

  1. Open the first image in Preview
  2. Show thumbnails (Command-option-2)
  3. Drag any additional images to the sidebar

After this we diverge:

  1. Select all image thumbnails in the sidebar (select one by clicking, then Command-A)
  2. File > Export Selected Images...
  3. Select or create a folder to hold your temporary images, set Format to PDF, and click Choose
  4. Close all original images
  5. Open the LAST exported PDF in Preview (this will become the last page)
  6. Drag all the other exported PDFs to the sidebar and drop ON TOP of the thumbnail for the exported PDF you just opened
  7. This should create a multipage PDF with the images in the same order they were in the Finder. Rename it so you can find it easily, save and you're done.
Dave
  • 126
  • 1
  • 3
  • This method worked very well for me. The Accepted Answer is very convenient, but as @Dave mentioned, doesn't work so well if your images are different sizes. The Accepted Answer's method also results in a margin around the edge of the PDF, presumably because the print dialog automatically adds a bleed edge. Also, Preview allows you to drag and drop _all_ the other PDFs and add them to the first (or last) PDF in one fell swoop. You can also reorder the pages in the resulting PDF by dragging and dropping. – Zkoh May 22 '15 at 03:33
  • Doesn't work on Yosemite. Step 2 shows a warning alert and exits the process. – a20 Sep 23 '15 at 13:40
4

I highly recommend the Python CLI program img2pdf for lossless conversion:

https://gitlab.mister-muffin.de/josch/img2pdf

Example usage:

img2pdf img1.png img2.jpg -o out.pdf
2

On more current versions of OSX, you may be better off using the native command line tool sips - see the answered Stack Overflow question 6349984, which converts from pdf to png. It should be far easier to script sips (which has been available since ~2009) than click multiple times within Preview.

Essentially,

sips -s format pdf input-png-file-path --out output-pdf-file-path
Kamil Maciorowski
  • 69,815
  • 22
  • 136
  • 202
Jason
  • 21
  • 1
1

MacOS 12.6

Allows you to do this in 3 seconds:

  1. In Finder Mark all PNGs you want to convert
  2. Right click
  3. Select Quick Actions
  4. Select Create PDF

Bonus this also works with if you have mixed file types: E.g. If you want to convert JPEGs and PNGs and PDFs into one single PDF!

enter image description here

ilam engl
  • 111
  • 2
0

A much simpler way is to use the rather overlooked app Automator, that you find in the Applications folder.

This link shows exactly how: Use Automator to combine your research photos into one PDF

  • 1
    Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change. – DavidPostill May 02 '17 at 10:40