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

Ross Moore ross at ics.mq.edu.au
Sun Jan 3 01:42:01 CET 2010

Hi James, Martijn, Reinhard,

On 03/01/2010, at 10:38 AM, James Quirk wrote:

> Martin,
> On Sat, 2 Jan 2010, martijn.list wrote:
>> Hi Reinhard,
>> Interesting workaround (attaching the key). The only problem I  
>> have with PDF
>> attachments is that I want the PDF to work with all PDF readers.  
>> The PDF is an
>> installation manual for my open source project and I want it to  
>> work even when
>> the PDF reader does not support attachments.
>> I tried to insert spaces etc. but it seems that all spaces are  
>> removed. I have
>> search the web quite intensively for a solution but haven't found  
>> one. You
>> would think that this is problematic for others as well, for  
>> example when
>> including source code snippets. I have tried the listings package  
>> (which is
>> used for including source code) but it suffered from the same  
>> problem.
> Another approach would be to use PDF's /ActualTex facility.

Yes, this is a good way to go ...

> For example, process this LaTeX and then try copy and pasting
> the text 'PGP-SIG'
> %--------- start example --------------
> \pdfminorversion=5
> \documentclass{article}
> \begin{document}
> \pdfliteral direct {%
>  /Span
>     <</ActualText
> (-----BEGIN PGP PUBLIC KEY BLOCK-----\string\r
> Version: GnuPG v1.4.9 (GNU/Linux)\string\r
> \string\r
> mQGiBElPrxcRBADTrz89p8FEAC/DEpNmbanNruED96RAuE0FRgbERqvgeSB7SVeW 
> \string\r
> [snip]\string\r
> TrzgYl9YhiNdY7s=\string\r
> =4Rpa\string\r
> -----END PGP PUBLIC KEY BLOCK-----\string\r
> )>>
>   BDC
>  }%
>  \pdfliteral direct {EMC}
> \end{document}
> %------------ end example ---------------
> The resultant PDF only works with Adobe Reader

  ... and it should also work with Poppler-based software.
But it does not work with MacOS X.

There are ways to put a \r  character into the PDF page stream,
but with my testing, I've been unable to get anything that works
correctly upon  Copy/Paste  under both Adobe and MacOS .
Very frustrating.

It seems that MacOS converts both \n and \r to the null character ^@ ;
i.e., ASCII 0, or  HEX x00 .
It must use heuristics about vertical moves to deduce when a new line
of text begins.

Adobe seems to do this too, but the /ActualText  mechanism gives a way
to override this, for Copy/Paste.

> and so is
> probably not want you want, but I thought I'd pass it across
> for completness.

I'd expect that any attempt to pass a PGP keys via Copy/Paste
is doomed to failure with different browsers, simply due to
the way the browsers and OSs might handle line-endings.

> James
>> Kind regards,
>> Martijn Brinkers

Hope this helps.


  And a Happy New Year to all!

Ross Moore                                       ross at maths.mq.edu.au
Mathematics Department                           office: E7A-419
Macquarie University                             tel: +61 (0)2 9850 8955
Sydney, Australia  2109                          fax: +61 (0)2 9850 8114

More information about the pdftex mailing list