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)下獲得許可。
該軟件是按照“原樣”分發的,沒有明示或暗示的任何形式的保證或條件。