when using -repage a4 I get a invalid argument for option '-repage': a4
–
ScolytusMar 7 '14 at 11:36

@Scolytus, on a Fedora 19 system I've observed a similar issue - it seems that -repage does not support the a4 name anymore. I've worked around this via shell arithmetic: -repage $((150*8.27))x$((150*11.69))
–
maxschlepzigMar 7 '14 at 15:17

I assume those magic numbers are 150dpi, and A4 expressed in legacy units?
–
Michael ScheperMar 19 at 3:07

where the target density is dynamically determined by calculating the width divided by 8.27 (which is the width in inch of an A4 page). the -repage a4 parameter can be omitted most of the time but i've had a few cases where the resulting .pdf would have a different format sligtly off the A4 dimensions of 210x297mm (8.27x11.6")

I was struggling with that stuff, too. Based on the above info, I wrote a script which adds alphabetically sorted image files into a single PDF.

Some variables are settable inside the script. It depends on ImageMagick and pdftk.

NB: If the input image has a higher resolution (dpi) than the wanted resolution of output.pdf, the image is resampled to the lower resolution. Otherwise, the image is not resampled and it is only extended to fit the page canvas.