如何使用Perl在PDF文档中搜索和替换?

时间:2021-09-25 21:04:07

Does anyone know of a free Perl program (command line preferable), module, or anyway to search and replace text in a PDF file without using it like an editor.

有没有人知道一个免费的Perl程序(命令行更好),模块,或者无论如何都可以搜索和替换PDF文件中的文本而不像编辑器那样使用它。

Basically I want to write a program (in Perl preferably) to automate replacing certain words (e.g. our old address) in a few hundred PDF files. I could use any program that supports command line arguments. I know there are many modules on CPAN that manipulate or create pdfs but they don't have (that I've seen) any sort of simple search and replace.

基本上我想写一个程序(最好是Perl)来自动替换几百个PDF文件中的某些单词(例如我们的旧地址)。我可以使用任何支持命令行参数的程序。我知道CPAN上有很多模块可以操作或创建pdf,但它们没有(我见过)任何简单的搜索和替换。

Thanks in advance for any and all advice!!!

提前感谢任何和所有的建议!

2 个解决方案

#1


Take a look at CAM::PDF. More specifically the changeString method.

看看CAM :: PDF。更具体地说是changeString方法。

#2


How did you generate those PDFs in the first place? Search-and-replace in the original sources and re-generate PDFs seems to be more viable. Direct editing PDFs can be very difficult, and I'm not aware of any free tools that can do it easily.

你是如何创建这些PDF的?在原始资源中搜索和替换并重新生成PDF似乎更可行。直接编辑PDF可能非常困难,而且我不知道任何可以轻松完成的免费工具。

#1


Take a look at CAM::PDF. More specifically the changeString method.

看看CAM :: PDF。更具体地说是changeString方法。

#2


How did you generate those PDFs in the first place? Search-and-replace in the original sources and re-generate PDFs seems to be more viable. Direct editing PDFs can be very difficult, and I'm not aware of any free tools that can do it easily.

你是如何创建这些PDF的?在原始资源中搜索和替换并重新生成PDF似乎更可行。直接编辑PDF可能非常困难,而且我不知道任何可以轻松完成的免费工具。