Last active
March 23, 2016 17:11
-
-
Save keevitaja/7e8497111b1e48f2e736 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# you need pdftk pdfseparate inkscape | |
tmp_folder="tmp_folder" | |
files="" | |
output="" | |
mkdir $tmp_folder | |
echo "Splitting files ..." | |
pdfseparate "$@" $tmp_folder/%d_page.pdf | |
cd $tmp_folder | |
i=1 | |
for part in `ls *.pdf | sort -V`; do | |
tput cuu 1 && tput el | |
echo "Removing password from part $i ..." | |
if [ "$i" -lt "10" ]; then | |
output="0${part}" | |
mv $part $output | |
part=$output | |
fi | |
inkscape -z -f $part -A $part | |
files="$files $part" | |
((i+=1)) | |
done | |
tput cuu 1 && tput el | |
echo "Concatenating files ..." | |
pdftk $files cat output ../$(basename "$@" .pdf)_ok.pdf | |
tput cuu 1 && tput el | |
echo "Cleaning up ..." | |
cd .. | |
rm -rf $tmp_folder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment