Skip to content

Instantly share code, notes, and snippets.

@hylophile
Last active March 1, 2024 13:00
Show Gist options
  • Select an option

  • Save hylophile/7f419be7ba87ece018b4c85452010560 to your computer and use it in GitHub Desktop.

Select an option

Save hylophile/7f419be7ba87ece018b4c85452010560 to your computer and use it in GitHub Desktop.
annotate every page of some pdf files with some text
#!/usr/bin/env bash
pdf_dir="lec"
mkdir -p lec_out/lec
for file in "$pdf_dir"/*.pdf; do
filename=$(basename -- "$file")
filename_no_ext="${filename#lec_}"
filename_no_ext="${filename%.*}"
echo "$filename_no_ext" > filename.txt
echo pandoc "$filename_no_ext"
pandoc --pdf-engine=lualatex \
-V mainfont="DejaVu Sans" \
-V pagestyle=empty \
-V documentclass=scrartcl \
-V fontsize="20pt" \
-V geometry:margin=1cm \
filename.txt \
-o filename.pdf
echo pdftk lec_out/"$file"
pdftk "$file" stamp filename.pdf output lec_out/"$file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment