A novice, I am trying to write a handler combining image files into one PDF. The handler needs three inputs:
the sorted list of the image files
the folder where to save the output PDF
the file name of the output PDF
I have tried four different approaches scripting:
the GUI of “Preview” 2) a UNIX application
Adobe Acrobat Pro X
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?
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.
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.
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