跳到正文

OCR 文字识别

为扫描文档添加一个可搜索的文字层。

在你的设备上处理

这款工具完全在你的浏览器中运行。文件从不上传,你可以在浏览器的网络标签中亲自验证这一点。 亲自验证:打开浏览器的网络标签观察。你会看到一个查询你是否还有剩余任务的小请求,只包含工具名称和一段哈希,绝不会包含文件。

这款工具的作用

A scanned PDF is a picture of a document, so searching it finds nothing and selecting a word selects nothing. This renders each page, recognises the words on it, and draws them back over the image invisibly, so the page looks as it did and the words are suddenly there. Recognised pages are rebuilt from that rendering: they come out grayscale at the resolution you chose, and any links, form fields or annotations they carried do not survive. Pages that already have real text are left alone, byte for byte.

Reach for it whenever a document arrived as pictures rather than words: a contract someone scanned and emailed, a receipt photographed on a phone, a fifty-page report from an office machine, or an old paper you need to quote from without retyping it.

工作原理

  1. Drop the scan onto this page. PDFs work, and so do JPEG, PNG, WebP and TIFF images - an image becomes a one-page PDF first.
  2. Choose the language. English and Indonesian are installed, and the combined mode recognises both at once in a document that mixes them.
  3. Leave the mode on only pages without text unless you know for certain that every page is a scan.
  4. Set the resolution if you need to. 300 dpi suits ordinary print; go towards 400 for very small type, or down towards 150 for a long document on a slow machine.
  5. Choose whether you want the searchable PDF, a plain text file, or both, then press Run OCR.

Recognition costs something on the pages it touches, and it is better to know before than after. Each recognised page is rendered to a grayscale image at your chosen resolution, and the new page is that image with the invisible words drawn over it. Colour on those pages is gone, and their links, form fields and annotations are not carried across. Skipped pages are copied untouched. The file usually grows, sometimes a lot, because a 300 dpi page image is bigger than the compressed scan it replaced - Compress PDF is the normal second step.

The words have to land in the right place or a text layer is worse than none. The recogniser returns each word's box in the pixels of the rendered image, counting down from the top, while a PDF page counts up from the bottom, so every box is scaled by the render ratio and flipped. Words scored below 40 out of 100 are left out entirely: a confidently wrong word sends search to the wrong page, while a gap only sends it nowhere.

Nothing is uploaded, and that includes the recogniser itself. tesseract.js fetches its WebAssembly core and its language data from a third-party CDN unless told otherwise, which would have meant your scan quietly announcing itself to a third party the first time anyone here ran OCR, so all of it is served from this site instead. The cost is a one-off download. The benefit is that recognition involves nobody else at all, which you are welcome to check in the network tab.

Resolution decides both how accurate the reading is and how long you wait for it. Below about 200 dpi, thin serifs and small print break up and accuracy falls away quickly. Above 300 the gains get small while render time and output size keep climbing. 300 is the default because that is roughly where the curve flattens for ordinary body text.

这款工具做不到的事

  • Handwriting is not recognised. The engine is trained on printed type, and a handwritten page comes back as scattered nonsense rather than words.
  • Only English and Indonesian models are installed, so a document in another language cannot be read properly here.
  • Recognised pages are rebuilt as grayscale images, so colour is lost on them and their links, form fields and annotations do not survive.
  • The output is a machine's reading, not a proofread transcript. Faint scans, unusual typefaces, tables and tight columns all produce mistakes.

常见问题

识别有多准确?
对一份干净的 300 dpi 印刷文字扫描件,一页通常只带回寥寥几个错误,结果还会报告平均置信度分数,让你看到引擎如何评判自己的工作。淡薄的复印件、倾斜的页面、紧凑的分栏和装饰性字体都会把它拉低。得分低于 100 分中 40 分的词会被丢弃,而不是硬猜。
它能读哪些语言?
英语和印尼语,外加一个能在同一文档里同时处理两者的组合模式——对照着译文一起印出的合同很有用。让识别得以成立的正是语言模型,而随附的只有这两种,所以其他语言的文档不是这个工具能做好的事。
为什么第一次会下载好几兆字节?
那是识别引擎和它的语言数据,由本站而非第三方 CDN 提供,这样运行 OCR 不会悄悄联系别人。英语约 11 MB,印尼语约 4 MB。你的浏览器会缓存它们,所以第二次运行会立即开始,从此 OCR 完全断网也能用。
“只处理没有文字的页面”实际上做什么?
它会检查每一页是否已有文字层,只识别那些没有的。大多数扫描文档里至少有一页从未被扫描,对它运行 OCR 会用近似值替换掉准确的文字。如果整份文档已有文字,工具会直接说明,而不是运行后给出比原来更糟的东西。
它能识别手写吗?
不能。引擎是用印刷字体训练的,手写会作为噪声返回——那些字母只是像形状,而非词语。签名、页边的批注或手工填写的表单都识别不出来。同一页上的印刷文字仍然可以。
扫描件会被上传到什么地方吗?
不会。渲染在你浏览器的一个 Web Worker 里进行,识别在另一个里,连 WebAssembly 内核和语言数据都来自本站自己的源,而非 CDN。你可以直接验证:把页面加载一次,断开连接,再跑一份扫描件。

相关工具