Combine images into PDF using UNIX

A novice, I am trying to write a handler combining image files into one PDF. The handler needs three inputs:

  1. the sorted list of the image files
  2. the folder where to save the output PDF
  3. the file name of the output PDF

I have tried four different approaches scripting:

  1. the GUI of “Preview”
    2) a UNIX application
  2. Adobe Acrobat Pro X
  3. Automator

In order to stay focused, I discuss each approach in a different post.

The Unix application “/System/Library/Printers/Libraries/convert” converts image files into PDF. However, although using it with a “do shell script” command properly converts one file at a time, it does not seem willing to take a batch of files and join them into one output PDF.

My questions are:

  • Is there a way to do so?
  • Is there another more appropriate Unix application that I could use?

Thanks in advance. W.

I can’t be positive, but I think this sort of thing was asked before. Did you do a search?
My memory is that it’s not as easy as it seems on the surface, since no tool you specified really is suited to what amounts to page layout. InDesign can do it, and maybe straight up Cocoa/Objective-C if you’re experienced with that.

Hi,

didn’t test it yet, but the adobe Bridge (freeware) may be a solution as it offers the ability to built pdf contact sheets … and is scriptable

I would try Smile from satimage, which can convert an image file and save it to a PDF page of user-defined dimensions. Then you can combine the separate PDFs into one PDF file of that dimension. Smile is free and useful for many other things too.

wladdy,
maybe these snippets are helpful for you:

property makepdf : "'/System/Library/Image Capture/Automatic Tasks/MakePDF.app'"

tell application "Finder" 
	set allf to the selection
	set ls to {}
	repeat with a in allf
		set pt to POSIX path of (get path of a)
		set ls to ls & " '" & pt & "'"
	end repeat
end tell
set cmd to "open -a " & makepdf & ls
do shell script cmd

bubble-sort routine:

to sort(L) -- expects an AppleScript list 
	set SL to {}
	set IL to {}
	repeat (count L) times
		set the low_item to 0
		repeat with i from 1 to (count L)
			if i is not in the IL then
				set this_item to item i of L
				if the low_item is 0 then
					set the low_item to this_item
					set the low_item_index to i
				else if this_item comes before the low_item then
					set the low_item to this_item
					set the low_item_index to i
				end if
			end if
		end repeat
		set the end of SL to the low_item
		set the end of the IL to the low_item_index
	end repeat
	return SL -- returns sorted list 
end sort