How to find and replace text in a existing PDF file with PDFTK (or other command line application) [closed]

You can try to modify content of your PDF as follows

  1. Uncompress the text streams of PDF

    pdftk file.pdf output uncompressed.pdf uncompress
    
  2. Use sed to replace your text with another

    sed -e "s/ORIGINALSTRING/NEWSTRING/g" <uncompressed.pdf >modified.pdf
    
  3. If this attempt was successful, re-compress the PDF with pdftk

    pdftk modified.pdf output recompressed.pdf compress
    

Note: This way is not successful every time, mainly due to font subsetting

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)