# Copy from PDF without line breaks at end of each line

When I produce the PDF, open it and copy the paragraph into notepad, there is a forced line break at the end of every line in the PDF. Is there a way to get over this, so that I can copy the paragraph as continuous text?

(Of course, I can just copy the paragraph from my .tex file. But the point is that I want other people to be able to copy text from my pdf.)

My MWE:

\documentclass[11pt,a4paper]{article}
\usepackage[cp1250]{inputenc}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{document}

-
You shouldn't use an input encoding in MWEs. The encoding depends on the OS/editor the user uses and therefore the setting will not be correct for other users which copy the MWEs. – Martin Scharrer Jan 13 '13 at 11:00
Does using pdftotext help? – Seamus Jan 13 '13 at 11:02
In addition you might also want to disable ligatures and hyphens, see Can we make ligatures copy-and-pastable?. – Martin Scharrer Jan 13 '13 at 11:08
@MartinScharrer Fortunately, the answer in your link does not disable ligatures, but makes them copyable. – mafp Jan 13 '13 at 11:25
@mafp: I meant disable ligatures when copy-and-pasting, not disabling them completely – Martin Scharrer Jan 13 '13 at 11:30

Copy the text in another text editor capable of removing line breaks. The editor I'm actually referring to is Sublime Text. You just have to follow these steps:

1. Install Sublime Text;
2. Install Package Control (this is not necessary but is almost a sine qua non);
3. Search for Paste PDF Text Block with Package Control and install it, or install it manually if you did not install Package Control.
4. Ctrl+alt+v the text you want to copy from a pdf file into a new file in Sublime Text.

You will not see any line breaks.

-

I can imagine a couple of possible solutions to this problem.

One would be that since latex knows what's a paragraph and what isn't, it could output some kind of metadata to the pdf file to mark paragraphs as such. This would have to be done in such a way as to make the pdf still a well-formed pdf that could be read by applications written according to Adobe's specs. Or the metadata could be somehow bundled along with the PDF, e.g., by zipping a PDF file and the metadata into the same file.

Another solution would be to use some kind of artificial intelligence algorithm to try to detect what's a paragraph ending and what's not. I don't think this is an easy problem to solve with good accuracy. E.g., Distributed Proofreaders uses human volunteers all over the planet to do this kind of thing for OCR'd texts. However, it might be possible to do it with some kind of decent precision. If there is such a heuristic algorithm, I'd imagine that you would find it by looking at OCR software.

The lack of a good solution to this problem (assuming I'm right) is basically due to Adobe's design decision to make PDF a presentation format, in which there is no importance attached to separation of formatting from content. Also, PDF is a handmaiden to Adobe. There is little likelihood of any solution gaining traction unless it's blessed by Adobe as the standard way to do it -- and it's not clear that Adobe has any economic interest in this issue.

-
PDF is an ISO standard now. – Martin Schröder Feb 2 '13 at 21:05
Adding the "metadata" could be done with PDF/A. – Martin Schröder Feb 2 '13 at 21:06
The first option seems more reasonable in this context. Do you have any idea if there some package to do it? If everything else fails one could have some Javascript code (for Acrobat) to copy each paragraph or at least the raw code for it. That would be really nice (e.g. to stream line, writing new documents from the PDF of old ones). – alfC Apr 19 '13 at 0:34