Last active
November 9, 2021 16:25
-
-
Save sambatyon/5123685 to your computer and use it in GitHub Desktop.
small scripts used to create a full pdf document.
This file contains hidden or 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
| #!/bin/bash | |
| if [[ `uname` =~ MINGW.* ]]; then | |
| GS=gswin64c | |
| else | |
| GS=gs | |
| fi | |
| output=$1 | |
| shift | |
| filelist=$@ | |
| filelist=$(echo ${filelist[*]} | tr ' ' "\n" | sort) | |
| processed_files="" | |
| for f in $filelist; do | |
| if [ ${f##*.} != pdf ]; then | |
| convert $f ${f%%.*}.pdf | |
| f=${f%%.*}.pdf | |
| fi | |
| processed_files="${processed_files}${f} " | |
| done | |
| filelist=$processed_files | |
| $GS -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=$output $filelist | |
| # Alternatively: | |
| gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=contract.pdf $(ls) | |
| # To split: | |
| gs -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dSAFER -o splitted.%d.pdf contract.pdf | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment