Skip to content

Instantly share code, notes, and snippets.

@HirbodBehnam
Created May 10, 2022 05:19
Show Gist options
  • Save HirbodBehnam/42a957c077923179fd374eb4a49a26d0 to your computer and use it in GitHub Desktop.
Save HirbodBehnam/42a957c077923179fd374eb4a49a26d0 to your computer and use it in GitHub Desktop.
Merge pdf files with gostscript and TOC
# From https://stackoverflow.com/a/56154217/4213397
for file in *.pdf; do
filename="${file%.*}"
gs -o "${filename}_toc.pdf" -sDEVICE=pdfwrite -c "[/Title ($filename) /OUT pdfmark" -f "$file"
done
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=final.pdf *_toc.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment