{"id":34946,"date":"2025-08-04T17:00:36","date_gmt":"2025-08-04T09:00:36","guid":{"rendered":"https:\/\/www.kdjingpai.com\/?p=34946"},"modified":"2025-08-04T17:00:36","modified_gmt":"2025-08-04T09:00:36","slug":"ocrmypdf","status":"publish","type":"post","link":"https:\/\/www.kdjingpai.com\/pt\/ocrmypdf\/","title":{"rendered":"OCRmyPDF\uff1a\u5c06\u626b\u63cfPDF\u8f6c\u4e3a\u53ef\u641c\u7d22\u6587\u672c\u7684\u5f00\u6e90\u5de5\u5177"},"content":{"rendered":"<p>OCRmyPDF \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4e13\u95e8\u7528\u4e8e\u4e3a\u626b\u63cf\u7684PDF\u6587\u4ef6\u6dfb\u52a0\u5149\u5b66\u5b57\u7b26\u8bc6\u522b\uff08OCR\uff09\u6587\u672c\u5c42\uff0c\u4f7f\u5176\u53d8\u4e3a\u53ef\u641c\u7d22\u3001\u53ef\u590d\u5236\u7684\u6587\u6863\u3002\u5b83\u57fa\u4e8ePython\u5f00\u53d1\uff0c\u4f7f\u7528Tesseract OCR\u5f15\u64ce\uff0c\u80fd\u51c6\u786e\u8bc6\u522b\u56fe\u50cf\u4e2d\u7684\u6587\u5b57\uff0c\u5e76\u5c06\u5176\u5d4c\u5165PDF\u4e2d\uff0c\u4fdd\u6301\u539f\u6587\u4ef6\u7684\u5e03\u5c40\u548c\u56fe\u50cf\u8d28\u91cf\u3002\u5de5\u5177\u652f\u6301\u591a\u8bed\u8a00\uff0c\u9002\u7528\u4e8eLinux\u3001Windows\u3001macOS\u7b49\u5e73\u53f0\uff0c\u8fd8\u63d0\u4f9bDocker\u955c\u50cf\uff0c\u65b9\u4fbf\u8de8\u5e73\u53f0\u90e8\u7f72\u3002OCRmyPDF \u9ed8\u8ba4\u751f\u6210PDF\/A\u683c\u5f0f\uff0c\u9002\u5408\u957f\u671f\u5b58\u6863\uff0c\u540c\u65f6\u652f\u6301\u9875\u9762\u6821\u6b63\u3001\u56fe\u50cf\u4f18\u5316\u7b49\u529f\u80fd\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u6587\u6863\u6570\u5b57\u5316\u548c\u5f52\u6863\u573a\u666f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-34947\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/08\/79edf7d9dd989d9.png\" alt=\"\" width=\"1080\" height=\"652\" srcset=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/08\/79edf7d9dd989d9.png 1080w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/08\/79edf7d9dd989d9-18x12.png 18w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>\u529f\u80fd\u5217\u8868<\/h2>\n<ul>\n<li>\u4e3a\u626b\u63cfPDF\u6dfb\u52a0\u53ef\u641c\u7d22\u7684OCR\u6587\u672c\u5c42\uff0c\u652f\u6301\u590d\u5236\u7c98\u8d34\u3002<\/li>\n<li>\u9ed8\u8ba4\u751f\u6210PDF\/A\u683c\u5f0f\uff0c\u9002\u5408\u957f\u671f\u6587\u6863\u5b58\u6863\u3002<\/li>\n<li>\u652f\u630139\u79cd\u8bed\u8a00\u7684\u6587\u5b57\u8bc6\u522b\uff0c\u8986\u76d6\u82f1\u8bed\u3001\u5fb7\u8bed\u3001\u4e2d\u6587\u7b49\u3002<\/li>\n<li>\u81ea\u52a8\u6821\u6b63\u9875\u9762\u503e\u659c\uff08deskew\uff09\u548c\u65cb\u8f6c\uff08rotate-pages\uff09\u3002<\/li>\n<li>\u4f18\u5316PDF\u6587\u4ef6\u5927\u5c0f\uff0c\u5e38\u751f\u6210\u6bd4\u8f93\u5165\u6587\u4ef6\u66f4\u5c0f\u7684\u8f93\u51fa\u3002<\/li>\n<li>\u652f\u6301\u591a\u6838\u5e76\u884c\u5904\u7406\uff0c\u63d0\u5347\u5927\u89c4\u6a21\u6587\u6863\u5904\u7406\u6548\u7387\u3002<\/li>\n<li>\u63d0\u4f9b\u8c03\u8bd5\u6a21\u5f0f\uff0c\u65b9\u4fbf\u9a8c\u8bc1OCR\u7ed3\u679c\u3002<\/li>\n<li>\u901a\u8fc7\u63d2\u4ef6\u652f\u6301\u529f\u80fd\u6269\u5c55\uff0c\u517c\u5bb9\u590d\u6742PDF\u7ed3\u6784\u3002<\/li>\n<li>\u81ea\u52a8\u4fee\u590d\u635f\u574f\u7684PDF\u6587\u4ef6\uff0c\u589e\u5f3a\u517c\u5bb9\u6027\u3002<\/li>\n<\/ul>\n<h2>\u4f7f\u7528\u5e2e\u52a9<\/h2>\n<h3>\u5b89\u88c5\u6d41\u7a0b<\/h3>\n<p>OCRmyPDF \u7684\u5b89\u88c5\u9700\u8981\u5728\u652f\u6301\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u914d\u7f6e\u4f9d\u8d56\u9879\uff0c\u5305\u62ecPython\u3001Tesseract\u3001Ghostscript\u7b49\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u5b89\u88c5\u6b65\u9aa4\uff0c\u9002\u7528\u4e8e\u5e38\u89c1\u64cd\u4f5c\u7cfb\u7edf\uff1a<\/p>\n<h4>Linux\uff08\u4ee5Ubuntu 22.04\u4e3a\u4f8b\uff09<\/h4>\n<ol>\n<li>\u786e\u4fdd\u7cfb\u7edf\u5df2\u5b89\u88c5Python 3\u548cpip\uff1a\n<pre><code>python3 --version\r\npip3 --version\r\n<\/code><\/pre>\n<\/li>\n<li>\u5b89\u88c5\u4f9d\u8d56\u9879\uff1a\n<pre><code>sudo apt update\r\nsudo apt install tesseract-ocr ghostscript python3-pip pngquant\r\n<\/code><\/pre>\n<\/li>\n<li>\u4f7f\u7528pip\u5b89\u88c5OCRmyPDF\uff1a\n<pre><code>pip3 install ocrmypdf\r\n<\/code><\/pre>\n<\/li>\n<li>\u9a8c\u8bc1\u5b89\u88c5\uff1a\n<pre><code>ocrmypdf --version\r\n<\/code><\/pre>\n<p>\u5982\u679c\u663e\u793a\u7248\u672c\u53f7\uff0c\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002<\/li>\n<\/ol>\n<h4>Windows<\/h4>\n<ol>\n<li>\u5b89\u88c5Python 3\uff08\u5efa\u8bae\u901a\u8fc7\u5b98\u7f51\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\uff09\u3002<\/li>\n<li>\u5b89\u88c5Tesseract\u548cGhostscript\uff08\u63a8\u8350\u4f7f\u7528Chocolatey\u5305\u7ba1\u7406\u5668\uff09\uff1a\n<pre><code>choco install tesseract ghostscript\r\n<\/code><\/pre>\n<\/li>\n<li>\u4f7f\u7528pip\u5b89\u88c5OCRmyPDF\uff1a\n<pre><code>pip install ocrmypdf\r\n<\/code><\/pre>\n<\/li>\n<li>\u786e\u8ba4\u5b89\u88c5\u5b8c\u6210\uff1a\n<pre><code>ocrmypdf --version\r\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<h4>macOS\uff08\u4f7f\u7528Homebrew\uff09<\/h4>\n<ol>\n<li>\u5b89\u88c5Homebrew\uff08\u5982\u679c\u672a\u5b89\u88c5\uff09\uff1a\n<pre><code>\/bin\/bash -c \"$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/HEAD\/install.sh)\"\r\n<\/code><\/pre>\n<\/li>\n<li>\u5b89\u88c5\u4f9d\u8d56\u9879\uff1a\n<pre><code>brew install tesseract ghostscript ocrmypdf\r\n<\/code><\/pre>\n<\/li>\n<li>\u9a8c\u8bc1\u5b89\u88c5\uff1a\n<pre><code>ocrmypdf --version\r\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<h4>Docker\u5b89\u88c5<\/h4>\n<ol>\n<li>\u786e\u4fddDocker\u5df2\u5b89\u88c5\u5e76\u8fd0\u884c\uff1a\n<pre><code>docker run hello-world\r\n<\/code><\/pre>\n<\/li>\n<li>\u62c9\u53d6OCRmyPDF\u955c\u50cf\uff1a\n<pre><code>docker pull jbarlow83\/ocrmypdf\r\n<\/code><\/pre>\n<\/li>\n<li>\u6807\u8bb0\u955c\u50cf\u4e3a\u4fbf\u6377\u540d\u79f0\uff1a\n<pre><code>docker tag jbarlow83\/ocrmypdf ocrmypdf\r\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<h3>\u4f7f\u7528\u65b9\u6cd5<\/h3>\n<p>OCRmyPDF \u662f\u4e00\u4e2a\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4f7f\u7528\u7b80\u5355\u4f46\u529f\u80fd\u5f3a\u5927\u3002\u57fa\u672c\u547d\u4ee4\u683c\u5f0f\u4e3a\uff1a<\/p>\n<pre><code>ocrmypdf [\u9009\u9879] \u8f93\u5165\u6587\u4ef6 \u8f93\u51fa\u6587\u4ef6\r\n<\/code><\/pre>\n<h4>\u57fa\u672c\u64cd\u4f5c<\/h4>\n<ol>\n<li><strong>\u7b80\u5355OCR\u8f6c\u6362<\/strong>\uff1a<br \/>\n\u5c06\u626b\u63cf\u7684PDF\u8f6c\u6362\u4e3a\u53ef\u641c\u7d22\u7684PDF\uff1a<\/p>\n<pre><code>ocrmypdf input.pdf output.pdf\r\n<\/code><\/pre>\n<p>\u8fd9\u4f1a\u5904\u7406<code>input.pdf<\/code>\uff0c\u751f\u6210\u5e26\u6709OCR\u6587\u672c\u5c42\u7684<code>output.pdf<\/code>\u3002<\/li>\n<li><strong>\u6307\u5b9a\u8bed\u8a00<\/strong>\uff1a<br \/>\n\u652f\u6301\u591a\u8bed\u8a00OCR\uff0c\u4f8b\u5982\u5904\u7406\u5305\u542b\u82f1\u6587\u548c\u4e2d\u6587\u7684PDF\uff1a<\/p>\n<pre><code>ocrmypdf -l eng+chi_sim input.pdf output.pdf\r\n<\/code><\/pre>\n<p>\u8bed\u8a00\u4ee3\u7801\u53ef\u5728Tesseract\u6587\u6863\u4e2d\u67e5\u627e\u3002<\/li>\n<li><strong>\u9875\u9762\u6821\u6b63\u548c\u4f18\u5316<\/strong>\uff1a<br \/>\n\u81ea\u52a8\u6821\u6b63\u503e\u659c\u5e76\u751f\u6210PDF\/A\u683c\u5f0f\uff1a<\/p>\n<pre><code>ocrmypdf --deskew --output-type pdfa input.pdf output.pdf\r\n<\/code><\/pre>\n<\/li>\n<li><strong>\u5e76\u884c\u5904\u7406<\/strong>\uff1a<br \/>\n\u4f7f\u7528\u591a\u6838\u52a0\u901f\u5904\u7406\uff1a<\/p>\n<pre><code>ocrmypdf --jobs 4 input.pdf output.pdf\r\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<h4>\u7279\u8272\u529f\u80fd\u64cd\u4f5c<\/h4>\n<ul>\n<li><strong>\u9875\u9762\u65cb\u8f6c<\/strong>\uff1a\u81ea\u52a8\u68c0\u6d4b\u5e76\u4fee\u590d\u9875\u9762\u65b9\u5411\uff1a\n<pre><code>ocrmypdf --rotate-pages input.pdf output.pdf\r\n<\/code><\/pre>\n<p>\u53ef\u901a\u8fc7<code>--rotate-pages-threshold<\/code>\u8bbe\u7f6e\u65cb\u8f6c\u9608\u503c\u3002<\/li>\n<li><strong>\u56fe\u50cf\u6e05\u7406<\/strong>\uff1a\u5728OCR\u524d\u6e05\u7406\u56fe\u50cf\uff0c\u63d0\u5347\u8bc6\u522b\u51c6\u786e\u6027\uff1a\n<pre><code>ocrmypdf --clean input.pdf output.pdf\r\n<\/code><\/pre>\n<\/li>\n<li><strong>\u8c03\u8bd5\u6a21\u5f0f<\/strong>\uff1a\u9a8c\u8bc1OCR\u7ed3\u679c\uff0c\u751f\u6210\u8be6\u7ec6\u65e5\u5fd7\uff1a\n<pre><code>ocrmypdf --verbose 2 input.pdf output.pdf\r\n<\/code><\/pre>\n<\/li>\n<li><strong>\u8df3\u8fc7\u5df2\u6709\u6587\u672c<\/strong>\uff1a\u907f\u514d\u91cd\u590d\u5904\u7406\u5df2\u6709\u6587\u672c\u7684\u9875\u9762\uff1a\n<pre><code>ocrmypdf --skip-text input.pdf output.pdf\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<h4>Docker\u4f7f\u7528<\/h4>\n<p>\u4f7f\u7528Docker\u8fd0\u884cOCRmyPDF\uff0c\u9002\u5408\u65e0\u672c\u5730\u73af\u5883\u7684\u573a\u666f\uff1a<\/p>\n<pre><code>docker run --rm -v $(pwd):\/data ocrmypdf \/data\/input.pdf \/data\/output.pdf\r\n<\/code><\/pre>\n<p>\u6b64\u547d\u4ee4\u5c06\u5f53\u524d\u76ee\u5f55\u7684<code>input.pdf<\/code>\u5904\u7406\u540e\u8f93\u51fa\u5230<code>output.pdf<\/code>\u3002<\/p>\n<h3>\u6ce8\u610f\u4e8b\u9879<\/h3>\n<ul>\n<li>\u786e\u4fdd\u8f93\u5165PDF\u662f\u626b\u63cf\u6587\u6863\uff0c\u542b\u6587\u672c\u7684PDF\u53ef\u80fd\u9700\u7528<code>--skip-text<\/code>\u3002<\/li>\n<li>Tesseract\u8bed\u8a00\u5305\u9700\u5355\u72ec\u5b89\u88c5\u4ee5\u652f\u6301\u591a\u8bed\u8a00\uff0c\u4f8b\u5982\uff1a\n<pre><code>sudo apt install tesseract-ocr-chi-sim\r\n<\/code><\/pre>\n<\/li>\n<li>\u5bf9\u4e8e\u590d\u6742PDF\uff0c\u5efa\u8bae\u542f\u7528<code>--verbose<\/code>\u67e5\u770b\u8be6\u7ec6\u65e5\u5fd7\uff0c\u4fbf\u4e8e\u6392\u67e5\u95ee\u9898\u3002<\/li>\n<\/ul>\n<h2>\u5e94\u7528\u573a\u666f<\/h2>\n<ol>\n<li><strong>\u6587\u6863\u6570\u5b57\u5316<\/strong><br \/>\n\u5c06\u7eb8\u8d28\u6587\u6863\u626b\u63cf\u4e3aPDF\u540e\uff0c\u4f7f\u7528OCRmyPDF\u6dfb\u52a0\u6587\u672c\u5c42\uff0c\u65b9\u4fbf\u641c\u7d22\u548c\u590d\u5236\u5185\u5bb9\uff0c\u9002\u5408\u6863\u6848\u7ba1\u7406\u6216\u6cd5\u5f8b\u6587\u4ef6\u5b58\u6863\u3002<\/li>\n<li><strong>\u5b66\u672f\u7814\u7a76<\/strong><br \/>\n\u7814\u7a76\u4eba\u5458\u53ef\u5c06\u626b\u63cf\u7684\u5b66\u672f\u8bba\u6587\u8f6c\u4e3a\u53ef\u641c\u7d22PDF\uff0c\u4fbf\u4e8e\u63d0\u53d6\u5f15\u7528\u6216\u5173\u952e\u8bcd\uff0c\u63d0\u9ad8\u6587\u732e\u7ba1\u7406\u6548\u7387\u3002<\/li>\n<li><strong>\u4f01\u4e1a\u5f52\u6863<\/strong><br \/>\n\u4f01\u4e1a\u53ef\u6279\u91cf\u5904\u7406\u626b\u63cf\u7684\u5408\u540c\u3001\u53d1\u7968\uff0c\u751f\u6210PDF\/A\u683c\u5f0f\uff0c\u786e\u4fdd\u957f\u671f\u4fdd\u5b58\u548c\u6cd5\u5f8b\u5408\u89c4\u6027\u3002<\/li>\n<li><strong>\u591a\u8bed\u8a00\u6587\u6863\u5904\u7406<\/strong><br \/>\n\u5904\u7406\u591a\u8bed\u8a00\u626b\u63cf\u6587\u6863\uff0c\u5982\u4e2d\u82f1\u6df7\u5408\u5408\u540c\uff0cOCRmyPDF\u53ef\u8bc6\u522b\u591a\u79cd\u8bed\u8a00\u5e76\u5d4c\u5165\u6587\u672c\u3002<\/li>\n<\/ol>\n<h2>QA<\/h2>\n<ol>\n<li><strong>OCRmyPDF\u652f\u6301\u54ea\u4e9b\u64cd\u4f5c\u7cfb\u7edf\uff1f<\/strong><br \/>\n\u652f\u6301Linux\u3001Windows\u3001macOS\u548cFreeBSD\uff0c\u4e5f\u53ef\u901a\u8fc7Docker\u8de8\u5e73\u53f0\u4f7f\u7528\u3002<\/li>\n<li><strong>\u5982\u4f55\u5904\u7406\u975e\u82f1\u6587\u6587\u6863\uff1f<\/strong><br \/>\n\u4f7f\u7528<code>-l<\/code>\u6307\u5b9a\u8bed\u8a00\u4ee3\u7801\uff0c\u5982<code>-l chi_sim<\/code>\u5904\u7406\u4e2d\u6587\uff0c\u9700\u5b89\u88c5\u5bf9\u5e94\u8bed\u8a00\u5305\u3002<\/li>\n<li><strong>\u8f93\u51fa\u6587\u4ef6\u6bd4\u8f93\u5165\u5927\u600e\u4e48\u529e\uff1f<\/strong><br \/>\n\u4f7f\u7528<code>--optimize 1<\/code>\u6216\u5b89\u88c5JBIG2\u7f16\u7801\u5668\u4ee5\u538b\u7f29\u6587\u4ef6\u5927\u5c0f\u3002<\/li>\n<li><strong>\u5982\u4f55\u9a8c\u8bc1OCR\u7ed3\u679c\uff1f<\/strong><br \/>\n\u4f7f\u7528<code>--verbose 2<\/code>\u751f\u6210\u8be6\u7ec6\u65e5\u5fd7\uff0c\u6216\u68c0\u67e5\u8f93\u51faPDF\u7684\u53ef\u590d\u5236\u6587\u672c\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>OCRmyPDF \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4e13\u95e8\u7528\u4e8e\u4e3a\u626b\u63cf\u7684PDF\u6587\u4ef6\u6dfb\u52a0\u5149\u5b66\u5b57\u7b26\u8bc6\u522b\uff08OCR\uff09\u6587\u672c\u5c42\uff0c\u4f7f\u5176\u53d8\u4e3a\u53ef\u641c\u7d22\u3001\u53ef\u590d\u5236\u7684\u6587\u6863\u3002\u5b83\u57fa\u4e8ePython\u5f00\u53d1\uff0c\u4f7f\u7528Tesseract OCR\u5f15\u64ce\uff0c\u80fd\u51c6\u786e\u8bc6\u522b\u56fe\u50cf\u4e2d\u7684\u6587\u5b57\uff0c\u5e76\u5c06\u5176\u5d4c\u5165PDF\u4e2d\uff0c\u4fdd\u6301&#8230;<\/p>\n","protected":false},"author":1,"featured_media":32782,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[425,20,502,499],"tags":[230,252],"class_list":["post-34946","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai-professional","category-tool","category-text-recognition","category-document-extraction","tag-aikaiyuanxiangmu","tag-markdown"],"_links":{"self":[{"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/posts\/34946","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/comments?post=34946"}],"version-history":[{"count":0,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/posts\/34946\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/media\/32782"}],"wp:attachment":[{"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/media?parent=34946"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/categories?post=34946"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/tags?post=34946"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}