如何找到并与PDFTK(或其他命令行应用程序)一个现有的PDF文件替换文本 [英] How to find and replace text in a existing PDF file with PDFTK (or other command line application)

查看:173
本文介绍了如何找到并与PDFTK(或其他命令行应用程序)一个现有的PDF文件替换文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的PDF文档的每一页上以该字符串的行:

I have on each page of my PDF document a line with this string:

%替换%

这我想找到并用另一个字符串替换。

Which I'd like to find and replace with another string.

有谁知道如何使用一些命令行应用程序做到这一点,如PDFTK?

Does anyone know how to do this with some command line application such as PDFTK?

这<一个href=\"http://stackoverflow.com/questions/7746687/pdf-insert-a-line-of-text-into-an-existing-pdf-file\">folk给了我一个重要的线索,但是我想的东西更加直接。

This folk gave me an important clue however I'd like something more direct.

感谢。

推荐答案

您可以尝试修改您的PDF内容如下:

You can try to modify content of your PDF as follows


  1. Uncom preSS PDF的文本流

  1. Uncompress the text streams of PDF

pdftk file.pdf output uncompressed.pdf uncompress


  • 使用 SED 替换为另一个文本

    sed -e "s/ORIGINALSTRING/NEWSTRING/g" <uncompressed.pdf >modified.pdf
    


  • 如果这个尝试成功,重新COM preSS与PDF的 PDFTK

    pdftk modified.pdf output recompressed.pdf compress
    


  • 注意:这种方式是不是成功的每次的,主要是由于字体子集

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

    这篇关于如何找到并与PDFTK(或其他命令行应用程序)一个现有的PDF文件替换文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆