Is there an easy way how to add a filepath (or a string) to a printed pdf using lp, convert, pdftk, python
or friends?
I want to print a bunch of pdf files with watermarks/headers which are parts of the file-path.
Is there an easy way how to add a filepath (or a string) to a printed pdf using lp, convert, pdftk, python
or friends?
I want to print a bunch of pdf files with watermarks/headers which are parts of the file-path.
I have found a semi-easy solution using pdftk, enscript, iconv, ps2pdf
in the following script:
#!/bin/bash
IFS=$'\n' # for files with spaces https://unix.stackexchange.com/questions/9496/looping-through-files-with-spaces-in-the-names
for pdf in $( ls */*.pdf ) ; do
echo $pdf
# create a watermark and handle encoding properly
echo $pdf | iconv -c -f utf-8 -t ISO-8859-2 | enscript -o - | ps2pdf - stamp.pdf
pdftk $pdf background stamp.pdf output out.pdf
rm stamp.pdf
lp -d printer out.pdf
rm out.pdf
echo ""
done
Any comments are welcome.