如何在保留格式的同時從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
  • 閱讀 ( 44 )
  • 分類:網際網路

你可能感興趣的文章

4種方式開源軟體不夠好

...obatprodc有效地建立和編輯pdf所需的一切知識。您還將學習如何對PDF進行數字簽名,如何比較不同的PDF文件,等等。 ...

  • 發佈於 2021-03-12 12:02
  • 閲讀 ( 53 )

如何在ios 11中使用蘋果強大的新notes功能

... 今天我們來看看iOS 11中的一些功能,以及如何使用它們。 ...

  • 發佈於 2021-03-13 02:29
  • 閲讀 ( 50 )

如何對mac上的檔案和資料夾進行密碼保護

... 今天我們將介紹如何在Mac上保護單個檔案和資料夾的密碼。 ...

  • 發佈於 2021-03-14 01:15
  • 閲讀 ( 50 )

免費與付費ocr軟體:比較microsoft onenote和nuance omnipage

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

  • 發佈於 2021-03-14 02:31
  • 閲讀 ( 59 )

介紹瞭如何在photoshop中儲存高質量的影象

使用Photoshop的使用者介面有點像在洞穴般的人行道上漫步。有這麼多的曲折,你不知道從哪裡開始,或你走向何方。也就是說,直到一個專案需要一個特定的能力。 ...

  • 發佈於 2021-03-17 01:54
  • 閲讀 ( 43 )

如何從pdf中提取影象並在任何地方使用它們

... 有許多工具可以修補PDF文件。今天,我們就來看看如何像鎖匠一樣挑它,“偷”一個形象,出來不留痕跡。讓我們看看從PDF中提取影象的一些方法。 ...

  • 發佈於 2021-03-17 18:01
  • 閲讀 ( 44 )

如何在microsoft word中建立專業報告和文件

... 我們有一個關於如何在Word中建立目錄頁的完整教程。 ...

  • 發佈於 2021-03-17 18:18
  • 閲讀 ( 53 )

如何使用ocr將手寫影象轉換為文字

您是否需要將手寫筆記數字化以編輯或索引它們?或者你想從手寫引文的圖片中複製文字?你需要的是一種光學字元識別(OCR)工具。 ...

  • 發佈於 2021-03-18 01:59
  • 閲讀 ( 44 )

如何在mac上覆制和貼上

想知道如何在你的新Mac上覆制和貼上嗎?畢竟,這是一個基本的行動,你必須每天使用。幸運的是,這個動作迅速而無痛,你很快就會掌握竅門。 ...

  • 發佈於 2021-03-20 10:54
  • 閲讀 ( 55 )

android的5個最佳pdf閱讀、編輯和註釋應用程式

... 您還可以共享PDF的特定頁面。這個應用程式讓你決定是保留註釋,展平它們,還是完全刪除它們。 ...

  • 發佈於 2021-03-22 06:58
  • 閲讀 ( 58 )