Skip to content

Instantly share code, notes, and snippets.

@azettl
Created March 22, 2021 21:59
Show Gist options
  • Save azettl/8546b17bd4880ce44c9b5b2b2ca596a9 to your computer and use it in GitHub Desktop.
Save azettl/8546b17bd4880ce44c9b5b2b2ca596a9 to your computer and use it in GitHub Desktop.
#!/bin/bash
# create temp files for html and pdf output
tin=$(tempfile) || exit
tout=$(tempfile) || exit
trap "rm -f -- '$tin'" EXIT
trap "rm -f -- '$tout'" EXIT
# write stdin to input temp file
echo "$(</dev/stdin)" > "$tin"
# execute pdfreactor in silent mode and write potential output to stderr
java -jar pdfreactor.jar -q -i "$tin" -o "$tout" 1>&2
# write pdf content to stdout
cat "$tout"
# remove temp files
rm -f -- "$tin"
rm -f -- "$tout"
trap - EXIT
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment