Combines all pdf extension files to single pdf. optimises pdf size.
uses ghostscript
#!/usr/bin/env bash | |
#@ Get pdf filelist | |
ls|grep \.pdf > filelist.pdf | |
## section to anipulate individual pdfs | |
## In this case last line is removed | |
filelist="" | |
mkdir -p temp | |
while IFS="" read -r p || [ -n "$p" ] | |
do | |
pdftk $p cat 1-r2 output temp/$p | |
filelist="$filelist temp/$pf" | |
done < filelist.txt | |
## Merge PDF | |
# cd temp ##Move to target folder where the manipulated pdfs are there | |
filelist=`ls |grep \.pdf` | |
mkdir -p output | |
gs -sDEVICE=pdfwrite \ | |
-dNOPAUSE -dBATCH -dSAFER \ | |
-sOutputFile=../output/full.pdf \ | |
$filelist | |
# cd .. |