如何在保留格式的同时从pdf复制文本?

PDF是一种普遍存在的文档格式,它非常适合在共享文档的同时保留字体、图像和跨平台的总体布局。但是,在从文档中复制和粘贴文本时,有没有一种简单的方法来保留这种格式?...

如何在保留格式的同时从pdf复制文本?

PDF是一种普遍存在的文档格式,它非常适合在共享文档的同时保留字体、图像和跨平台的总体布局。但是,在从文档中复制和粘贴文本时,有没有一种简单的方法来保留这种格式?

今天的问答环节是由SuperUser提供的,SuperUser是Stack Exchange的一个分支,是一个由社区驱动的问答网站分组。

问题

超级用户阅读器Colen正在寻找一种从PDF中提取文本的方法,同时保留格式:

When I copy text out of a PDF file and into a text editor, it ends up mangled in a variety of ways. Formatting like bold and italics are lost; soft line breaks within a paragraph of text are converted to hard line breaks; dashes to break a word over two lines are preserved even when they shouldn’t be; and single and double quotes are replaced with ? signs.

Ideally, I’d like to be able to copy text from a PDF and have formatting converted to HTML codes, “**art quotes” converted to ” and ‘, and line breaks done properly. Is there any way to do this?

对于Colen(和我们其他人)来说,有没有一种既快速又简单的方法可以在不牺牲格式的情况下获取抓取文本?

答案

超级用户贡献者Frabjous提供了一个结合了大量谨慎的解决方案:

Firstly, you have to understand what a PDF is. PDFs are designed to mimic a printed page, and they are designed only as an output format, not an input format. a PDF is basically a map containing the exact location of characters (individual letters or punctuation, etc.) or images. In most cases, a PDF does not even store information about where one word ends and another begins, much less things like soft breaks vs. hard breaks for paragraph endings.

(A few recent PDFs do store some information about this stuff, but that’s a new technology, and you’d be lucky to find PDFs like that. Even if you did, your PDF viewer might not know about it.)

Anyway, it’s up to your software to implement some kind of “artificial intelligence” to extract merely from the locati*** of individual characters what is a word, what is a paragraph, and so on. Different software is going to do this better than others, and it’s also going to depend on how the PDF was made. In any case, you should never expect perfect results. Having the output PDF is not the same as having the source document. Far better to try to obtain that if you can.

The standard solution to your kind of problem is to use Adobe Acrobat Professional (the expensive one, not the free reader) to convert the PDF to HTML. Even that is not going to get perfect results.

There is free software that can be used to extract text from PDFs with some of formatting intact, but again, don’t expect perfect results. See, e.g., calibre (which can convert to RTF format), pdftohtml/pdfreflow, or the AbiWord word processor (with all import/export plugins enabled). There’s also a PDF import plugin for OpenOffice.

But please don’t expect perfection with any of these results. You’re going against the grain here. PDF just is not meant as an editable input format.

如果你很难决定从哪个工具开始,Calibre是一个名副其实的文件瑞士**。您还可以使用它来转换PDF文件,以便在电子书阅读器上使用,并组织电子书/文档库。


有什么要补充的解释吗?在评论中发出声音。想从其他精通技术的Stack Exchange用户那里了解更多答案吗?在这里查看完整的讨论主题。

  • 发表于 2021-04-12 02:29
  • 阅读 ( 199 )
  • 分类:互联网

你可能感兴趣的文章

免费与付费ocr软件:比较microsoft onenote和nuance omnipage

... 如何使用ocr工具 ...

  • 发布于 2021-03-14 02:31
  • 阅读 ( 265 )

如何从pdf中提取图像并在任何地方使用它们

... 有许多工具可以修补PDF文档。今天,我们就来看看如何像锁匠一样挑它,“偷”一个形象,出来不留痕迹。让我们看看从PDF中提取图像的一些方法。 ...

  • 发布于 2021-03-17 18:01
  • 阅读 ( 176 )

如何在microsoft word中创建专业报告和文档

... 我们有一个关于如何在Word中创建目录页的完整教程。 ...

  • 发布于 2021-03-17 18:18
  • 阅读 ( 275 )

如何使用ocr将手写图像转换为文本

您是否需要将手写笔记数字化以编辑或索引它们?或者你想从手写引文的图片中复制文本?你需要的是一种光学字符识别(OCR)工具。 ...

  • 发布于 2021-03-18 01:59
  • 阅读 ( 221 )

如何在mac上复制和粘贴

想知道如何在你的新Mac上复制和粘贴吗?毕竟,这是一个基本的行动,你必须每天使用。幸运的是,这个动作迅速而无痛,你很快就会掌握窍门。 ...

  • 发布于 2021-03-20 10:54
  • 阅读 ( 236 )

注释的简单指南:如何注释PDF、电子书、图像和网站

... 注释如何有用? ...

  • 发布于 2021-03-25 04:26
  • 阅读 ( 414 )

将word文档保存为图像文件的5种方法

... 以下是如何将Word文档中的一个页面转换为带有屏幕截图的图像: ...

  • 发布于 2021-03-30 12:19
  • 阅读 ( 231 )

如何粘贴文本而不格式化几乎任何地方

...可以将Word的默认粘贴选项设置为“仅保留文本” 相关:如何更改Microsoft Word中的默认粘贴设置 如果这个键盘快捷键在你选择的应用程序中不起作用,那么总会有一种低技术的方法:打开一个像记事本这样的纯文本编辑器,将文...

  • 发布于 2021-04-01 23:30
  • 阅读 ( 197 )

如何将googleslides对象保存为图像

...保存包含对象的裁剪图像并在其他地方使用它。 相关:如何在几乎所有设备上截图

  • 发布于 2021-04-02 17:20
  • 阅读 ( 202 )

如何将电子邮件保存到硬盘

...但有时您可能需要保留一份副本作为脱机备份。下面介绍如何将电子邮件保存到硬盘,使其始终可用和可访问。 保存来自gmail的电子邮件 要保存来自Gmail的电子邮件,请打开电子邮件并单击“回复”按钮旁右上角的三个点。 ...

  • 发布于 2021-04-02 23:03
  • 阅读 ( 132 )
iy5js7203
iy5js7203

0 篇文章

相关推荐