Created
April 23, 2015 00:31
-
-
Save johnhany97/2e667d3a54b45b178aad to your computer and use it in GitHub Desktop.
Batch Replace specific text in PDF automatically using pdftk
This file contains hidden or 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
Create a file with this: | |
#!/bin/bash | |
oldtext=$1 | |
newtext=$2 | |
pdffile=$3 | |
cp $pdffile $pdffile.bak | |
pdftk $pdffile output $pdffile.tmp uncompress | |
sed -i "s/$oldtext/$newtext/g" $pdffile.tmp | |
pdftk $pdffile.tmp output $pdffile compress | |
rm -rf *.bak | |
rm -rf *.tmp | |
Then run this command: | |
for i in *.pdf ; do replacepdftext.sh oldword newword $i ; done | |
where replacepdftext.sh is the name of the file earlier created |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment