#!/bin/sh
#	convert multiple images to pdf and merge them into a single pdf
#	needs sam2p, available as a standard debian/ubuntu package
#	and pdfjoin from texlive-extra-utils
#	by Nick Manini v. May 29, 2017
pdfs=""
pdffile="images_output.pdf"
case $# in
0|1)	echo "usage: $0 input_imagefile(s) output_pdffile";;
*)	for i
	do
		if (test -f $i)
		then
		        cf=/tmp/conv.$$.$i".pdf"
			sam2p $i PDF: $cf
			echo converted $i
			pdfs=$pdfs" "$cf
		else
			pdffile=$i
		fi
	done
esac
pdfjoin $pdfs --outfile $pdffile


