PDF 转文本
把文字提取为纯 .txt 文件。
这款工具完全在你的浏览器中运行。文件从不上传,你可以在浏览器的网络标签中亲自验证这一点。 亲自验证:打开浏览器的网络标签观察。你会看到一个查询你是否还有剩余任务的小请求,只包含工具名称和一段哈希,绝不会包含文件。
这款工具的作用
This extracts the words from a PDF and writes them into a plain .txt file. A PDF does not store text as sentences - it stores glyphs at coordinates - so reading order, word boundaries and paragraph breaks are all reconstructed from the geometry of the page. Every extractor guesses that slightly differently, which is why the same document gives different output in different tools, and why there are two modes here rather than one.
Lifting a quotation out of a report without retyping it, feeding a document to a script or a language model, searching a book you only have as a PDF, or checking what a page actually contains when a table detector insists it found nothing.
工作原理
- Drop the PDF onto this page. One file at a time, up to 300 MB.
- Choose reading order for prose you intend to paste somewhere, or layout to keep columns and tables lined up with spaces.
- Decide whether pages are separated by a marker line and whether page numbers are printed into the file.
- Leave rejoin hyphenated words on so a word broken across a line break comes back together.
- Under advanced options, set a page range, or switch the encoding to UTF-8 with a BOM if Excel or Notepad will open the file.
- Press Convert to text and the .txt downloads on its own.
The two modes solve opposite problems. Reading order joins the lines of a paragraph back into flowing prose, which is what you want in an email, a script or a quotation. Layout mode keeps every line where it was on the page, padding with spaces so columns stay aligned - right for a table, a code listing or a form, and wrong for prose, where the padding becomes ragged whitespace you then strip out. If the output looks strange, the mode is usually why.
Rejoining hyphenated words is more careful than a search-and-replace. A hyphen at the end of a line is joined only when the character before it and the first character of the next line are both lowercase, so a word broken as inter- and national comes back as international, while a compound such as self-service, or a hyphen followed by a capitalised name, is left as written. The rule errs towards leaving a real hyphen alone rather than towards editing your text.
A scanned document is detected before any work happens. The first five pages are sampled for a text layer, and when there is none the tool stops and points at OCR, since a scan is a picture of words with nothing in it to extract. Reporting no text found would be technically true and practically useless.
The encoding option is small and saves a familiar afternoon. UTF-8 without a byte order mark is what a script, a git repository or a text editor wants. UTF-8 with a BOM is what makes Excel and Notepad recognise the file as UTF-8 instead of guessing a legacy code page and mangling every accented character. If names come out as strings of symbols, the BOM is what was missing.
Extraction runs in a Web Worker and the text file is written there too, so a confidential document is never sent anywhere to have its words read. The result reports the page count, the character and word counts and how many pages came out empty - often the quickest sign that part of a document is scanned while the rest is not.
这款工具做不到的事
- Columns, sidebars, headers and footnotes come out in the order the reconstruction decides on, which is not always the order a person reads them in. Layout mode is often clearer for those pages.
- A scanned page contains no text to extract. That is detected and reported with a link to OCR rather than writing an empty file.
常见问题
- 阅读顺序和版式有什么区别?
- 「阅读顺序」重建段落,把每一段的各行拼接成可以粘贴到任何地方的流动文本。「版式」通过用空格填充来保留页面的形状,这样在等宽视图下,列、表格和代码清单都保持对齐。散文用阅读顺序;当文本的水平位置带有意义时用版式。
- 我的 PDF 什么都没提取出来。为什么?
- 几乎可以肯定是因为它是扫描件。扫描的页面里放的是文字的照片,而不是文字,所以没有可供提取的文本层。在开始任何工作之前会先对前五页采样,如果没有,工具就会停止,并把你转到「OCR PDF」,它会把图片变成真正的文字,你随后就能提取。
- 提取出来的文本乱了。这能修好吗?
- 先试试版式模式——乱序的输出通常意味着一个多栏页面,它的各行被跨栏拼接了。版式会把每一栏保持在原处,这更易读也更易清理。有些文档还会以与阅读顺序无关的次序放置页眉、页脚和页边注释,而没有哪个提取器能可靠地知道得更清楚。
- 我打开文件时重音字符看起来不对。现在怎么办?
- 把编码切换为带 BOM 的 UTF-8 再转换一次。字节顺序标记会告诉 Excel 和记事本这个文件是 UTF-8,而不是让它们去猜某个旧的代码页,后者正是把一个重音字母变成两个符号的原因。给脚本、编辑器和版本控制用时,就保持纯 UTF-8。
- 提取文本时文档会被上传吗?
- 不会。PDF 的解析和文本文件的生成都在你的浏览器中进行,任何时刻都不会有东西被传输——当文档是合同或病历时,这值得一提。你可以在转换时看着开发者工具的网络标签来确认这一点,而且这款工具能离线工作。