Last active
May 12, 2024 14:08
-
-
Save MarkusH/7ff12f21b940b5c1637d59626b80675e to your computer and use it in GitHub Desktop.
Ghostscript Tools
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
#!/usr/bin/bash | |
set -e | |
# https://stackoverflow.com/a/70438840 | |
declare -a files=() | |
declare -a arr=($(echo "$2" | tr "," " ")) | |
# splitting | |
for i in "${arr[@]}"; do | |
gs -dBATCH -sDEVICE=pdfwrite -sPageList="$i" -dNOPAUSE -sOutputFile="$i".tmp "$1" | |
# reordering for combining | |
files+=("$i.tmp") | |
done | |
# combining to combine.pdf | |
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE="$3" -dBATCH "${files[@]}" | |
# removing temporary files | |
rm "${files[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment