Comment puis-je copier du texte d'un PDF tout en préservant la mise en forme?

Table des matières:

Comment puis-je copier du texte d'un PDF tout en préservant la mise en forme?
Comment puis-je copier du texte d'un PDF tout en préservant la mise en forme?

Vidéo: Comment puis-je copier du texte d'un PDF tout en préservant la mise en forme?

Vidéo: Comment puis-je copier du texte d'un PDF tout en préservant la mise en forme?
Vidéo: Récupérer le contenu masqué, caché d'une clé usb sur Windows - YouTube 2024, Avril
Anonim
PDF, le format de document omniprésent, est idéal pour partager des documents tout en préservant les polices, les images et la disposition générale sur toutes les plates-formes. Y a-t-il un moyen facile de conserver cette mise en forme lors de la copie et du collage de texte hors du document?
PDF, le format de document omniprésent, est idéal pour partager des documents tout en préservant les polices, les images et la disposition générale sur toutes les plates-formes. Y a-t-il un moyen facile de conserver cette mise en forme lors de la copie et du collage de texte hors du document?

La séance de questions et réponses d’aujourd’hui nous est offerte par SuperUser, une sous-division de Stack Exchange, un groupe de sites Web de questions-réponses dirigé par la communauté.

La question

Lecteur SuperUser Colen recherche un moyen d’extraire du texte à partir de PDF tout en préservant le formatage:

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?

Existe-t-il un moyen simple et rapide pour Colen (et le reste d’entre nous) d’obtenir un texte instantané sans sacrifier la mise en forme?

La réponse

Contributeur de SuperUser, Frabjous propose une solution combinée avec une forte dose de prudence:

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.

Si vous ne parvenez pas à choisir l'outil par lequel commencer, Calibre est un véritable couteau suisse de document. Vous pouvez également l'utiliser pour convertir des fichiers PDF à utiliser sur votre lecteur de livre électronique et organiser votre bibliothèque de livres / documents électroniques.

Avez-vous quelque chose à ajouter à l'explication? Sound off dans les commentaires. Voulez-vous lire plus de réponses d'autres utilisateurs de Stack Exchange doués en technologie? Découvrez le fil de discussion complet ici.

Conseillé: