[pdftex] Blank lines are ignored when copying-and-pasting from PDF

Reinhard Kotucha reinhard.kotucha at web.de
Sat Jan 2 19:53:38 CET 2010


On 2 January 2010 martijn.list wrote:

 > I'm including a PGP public key block in my document using with verbatim:
 > 
 > \begin{verbatim}
 > -----BEGIN PGP PUBLIC KEY BLOCK-----
 > Version: GnuPG v1.4.9 (GNU/Linux)
 > 
 > mQGiBElPrxcRBADTrz89p8FEAC/DEpNmbanNruED96RAuE0FRgbERqvgeSB7SVeW
 > [snip]
 > TrzgYl9YhiNdY7s=
 > =4Rpa
 > -----END PGP PUBLIC KEY BLOCK-----
 > \end{verbatim}
 > 
 > Now when I convert the Latex document to PDF (using pdflatex) the PDF 
 > document shows the blank line between ...GnuPG v1.4.9 (GNU/Linux) and 
 > mQGiBElP...
 > 
 > But, when I copy and paste the PGP key to a text editor it won't include 
 > the blank line. Because the blank line is mandatory the result will be 
 > an invalid PGP key. Is it possible to add a newline to the final PDF 
 > output to make sure that copy-and-paste will include the blank line?

This might be difficult because PDF has no concept of lines.  It only
contains information where text or graphics shall appear on the page.
I tested your example with ps2ascii (Ghostscript) and pdftotext (xpdf)
and both didn't even recognize ordinary line breaks.  I assume that
copy-and-paste will never be reliable if the exact formatting matters.

But I tried something different which might be an option, though
probably not supported by all PDF browsers:

Put the key into an external file "PGP.txt" and run the file below
through pdflatex:

\documentclass{article}
\usepackage{embedfile}
\embedfile[desc={PGP Public Key}]{PGP.txt}
\begin{document}
some text
\end{document}

In Adobe Reader, click on the paperclip icon in the bottom left corner
in order to extract the file.

Maybe it's possible to open the attachment panel by clicking on a
hyperlink in the text, but I never investigated this.  If necessary,
you have to read the documentation of the packages attachfile,
attachfile2, and embedfile more thoroughly than I did.

Regards,
  Reinhard

-- 
----------------------------------------------------------------------------
Reinhard Kotucha			              Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover	                      mailto:reinhard.kotucha at web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------


More information about the pdftex mailing list