Làm thế nào tôi có thể sao chép văn bản từ một PDF trong khi bảo quản định dạng?

Mục lục:

Làm thế nào tôi có thể sao chép văn bản từ một PDF trong khi bảo quản định dạng?
Làm thế nào tôi có thể sao chép văn bản từ một PDF trong khi bảo quản định dạng?

Video: Làm thế nào tôi có thể sao chép văn bản từ một PDF trong khi bảo quản định dạng?

Video: Làm thế nào tôi có thể sao chép văn bản từ một PDF trong khi bảo quản định dạng?
Video: Plex DVR & MCEBuddy - How To Remove / Skip Commercials and Make Recorded Files Smaller! - YouTube 2024, Tháng tư
Anonim
PDF, định dạng tài liệu phổ biến, rất tuyệt vời để chia sẻ tài liệu trong khi vẫn giữ phông chữ, hình ảnh và bố cục chung trên các nền tảng. Có cách nào dễ dàng, tuy nhiên, để bảo toàn định dạng đó khi sao chép và dán văn bản ra khỏi tài liệu?
PDF, định dạng tài liệu phổ biến, rất tuyệt vời để chia sẻ tài liệu trong khi vẫn giữ phông chữ, hình ảnh và bố cục chung trên các nền tảng. Có cách nào dễ dàng, tuy nhiên, để bảo toàn định dạng đó khi sao chép và dán văn bản ra khỏi tài liệu?

Phiên Hỏi & Đáp hôm nay đến với chúng tôi theo lịch sự của SuperUser - một phân khu của Stack Exchange, một nhóm các trang web Hỏi & Đáp do cộng đồng điều hành.

Câu hỏi

Bộ đọc siêu người dùng Colen đang tìm kiếm một cách để trích xuất văn bản từ các tệp PDF trong khi vẫn giữ nguyên định dạng:

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, “smart quotes” converted to” and ‘, and line breaks done properly. Is there any way to do this?

Có một cách nhanh chóng và dễ dàng cho Colen (và phần còn lại của chúng tôi) để lấy văn bản mà không bị mất định dạng?

Câu trả lời

Người đóng góp của SuperUser Frabjous cung cấp một giải pháp kết hợp với liều thận trọng cao:

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 locations 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.

Nếu bạn gặp khó khăn khi quyết định nên bắt đầu công cụ nào, Calibre là một tài liệu thật sự của con dao quân đội Thụy Sĩ. Bạn cũng có thể sử dụng nó để chuyển đổi các tập tin PDF để sử dụng trên trình đọc ebook của bạn và tổ chức thư viện ebook / tài liệu của bạn.

Có cái gì để thêm vào lời giải thích? Âm thanh trong các ý kiến. Bạn muốn đọc thêm câu trả lời từ những người dùng Stack Exchange có hiểu biết công nghệ khác? Xem toàn bộ chuỗi thảo luận tại đây.

Đề xuất: