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

独自空忆成欢 提交于 2019-11-27 18:35:40
Dingo

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!