Last active
April 2, 2018 11:11
-
-
Save mrbar42/2b5452f075106e256f2d092b828980f0 to your computer and use it in GitHub Desktop.
Convert images to one combined PDF file (based on pdftk and imagemagic)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
if [[ ! "$1" ]]; then | |
echo "Usage: pdfer page1.png page2.png..." | |
exit 1 | |
fi | |
output_file="combined.pdf" | |
pages="" | |
for file in ${@}; do | |
if [[ ! "$file" =~ .pdf$ ]]; then | |
convert "${file}" "${file}.pdf" | |
pages+=" ${file}.pdf" | |
else | |
pages+=" ${file}" | |
fi | |
done | |
pdftk ${pages} cat output ${output_file} | |
rm -f ${pages} | |
echo "Done - saved as $output_file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment