Created
June 1, 2012 21:36
-
-
Save mihaisoloi/2855278 to your computer and use it in GitHub Desktop.
Script for parsing csv table of contents and aggregating a number of pdfs with bookmarks using pdftk and gs
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 | |
files="" | |
options="" | |
title="" | |
pages=0 | |
page_number=1 | |
i=1 | |
for f in TCST\ *.pdf | |
do | |
pages=$(pdfinfo "$f" | grep Pages | awk '{print $2}') | |
#echo '~~~>>' + $pages | |
f=${f// /\\ } | |
title=$(awk "NR==${i}" 'ToC.csv') | |
#echo $i + '~~~~' + $title | |
((i++)) | |
options="${options} -c [\"/Page ${page_number} /View [/XYZ null null null] /Title (${title}) /OUT pdfmark\"" | |
page_number=$((${pages} + ${page_number})) | |
#echo $page_number | |
files="${files} ${f}" | |
done | |
#echo $files | |
#echo $options | |
echo "gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=TCST.pdf $options -dBATCH $files" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment