OCRMYPDF将OCR文本层添加到扫描的PDF文件中,从而搜索或复制它们。
ocrmypdf # it's a scriptable command line program
-l eng+fra # it supports multiple languages
--rotate-pages # it can fix pages that are misrotated
--deskew # it can deskew crooked PDFs!
--title " My PDF " # it can change output metadata
--jobs 4 # it uses multiple cores by default
--output-type pdfa # it produces PDF/A by default
input_scanned.pdf # takes PDF input (or images)
output_searchable.pdf # produces validated PDF output
有关最新更改的详细信息,请参见发行说明。
有关详细信息:请咨询文档。
我搜索了网络上的免费命令行工具到OCR PDF文件:我找到了很多,但它们都没有真正令人满意:
...所以我决定开发自己的工具。
支持Linux,Windows,MacOS和FreeBSD。 X64和ARM都可以使用Docker图像。
操作系统 | 安装命令 |
---|---|
Debian,Ubuntu | apt install ocrmypdf |
Linux的Windows子系统 | apt install ocrmypdf |
软呢帽 | dnf install ocrmypdf |
macos(自制) | brew install ocrmypdf |
MacOS(MacPorts) | port install ocrmypdf |
macos(nix) | nix-env -i ocrmypdf |
Linuxbrew | brew install ocrmypdf |
freebsd | pkg install py-ocrmypdf |
ubuntu snap | snap install ocrmypdf |
对于其他所有人,请参阅我们的文档以获取安装步骤。
OCRMYPDF使用Tesseract进行OCR,并依靠其语言包。对于Linux用户,您通常可以找到提供语言包的软件包:
# Display a list of all Tesseract language packs
apt-cache search tesseract-ocr
# Debian/Ubuntu users
apt-get install tesseract-ocr-chi-sim # Example: Install Chinese Simplified language pack
# Arch Linux users
pacman -S tesseract-data-eng tesseract-data-deu # Example: Install the English and German language packs
# brew macOS users
brew install tesseract-lang
然后,您可以将-l LANG
参数传递给OCRMYPDF,以提示它应该搜索的语言。可以请求多种语言。
OCRMYPDF支持Tesseract 4.1.1+。它将自动使用在PATH
环境变量上首先找到的任何版本。在Windows上,如果PATH
不提供Tesseract二进制,我们使用根据Windows注册表安装的最高版本号。
安装了OCRMYPDF后,可以通过以下方式访问命令语法的内置帮助:
ocrmypdf --help
我们的文档在阅读文档上提供。
请在我们的GITHUB问题页面上报告问题,然后遵循问题模板进行快速响应。
# Add an OCR layer and convert to PDF/A
ocrmypdf input.pdf output.pdf
# Convert an image to single page PDF
ocrmypdf input.jpg output.pdf
# Add OCR to a file in place (only modifies file on success)
ocrmypdf myfile.pdf myfile.pdf
# OCR with non-English languages (look up your language's ISO 639-3 code)
ocrmypdf -l fra LeParisien.pdf LeParisien.pdf
# OCR multilingual documents
ocrmypdf -l eng+fra Bilingual-English-French.pdf Bilingual-English-French.pdf
# Deskew (straighten crooked pages)
ocrmypdf --deskew input.pdf output.pdf
有关更多功能,请参见文档。
除所需的Python版本外,OCRMYPDF还需要外部程序安装Ghostscript和Tesseract OCR。 OCRMYPDF是纯Python,并且在几乎所有内容上运行:Linux,MacOS,Windows和FreeBSD。
如果没有公司和用户选择为功能开发和咨询查询提供支持,OCRMYPDF将不是今天的软件。我们很乐意讨论所有查询,无论是用于扩展现有功能集还是将OCRMYPDF集成到较大的系统中。
OCRMYPDF软件已获得Mozilla公共许可证2.0(MPL-2.0)的许可。该许可证允许将OCRMYPDF与其他代码集成,包括商业和封闭源,但要求您将您对OCRMYPDF进行源级修改。
OCRMYPDF的某些组件具有其他许可,如标准SPDX许可证标识符或DEP5版权和许可信息文件所示。一般而言,非核心代码是根据MIT许可的,并且文档和测试文件在Creative Commons ShareAlike 4.0(CC-BY-SA 4.0)下获得许可。
该软件是按照“原样”分发的,没有明示或暗示的任何形式的保证或条件。