views:

29

answers:

0

I'm trying to put some code examples in a pdf, but copying them out messes up the formatting and rearranges the lines, there's a lot of manual cleanup needed after pasting.

Is there a equivalent to html's pre for PDFs? For "this" block of text respect line breaks, spacing, and copy as plain text like its shown. The closest thing I can see is adding note annotations next to every code example.

To clarify more: its about being able to copy example code from an pdf without it getting all screwed up (line order, spacing, returns), its hit or miss. I'm assuming the problem it caused by the order in which the text blocks are broken apart and ordered internally vs where they are rendered on the page. So when doing a copy paste out of a pdf into say notepad you get back the internal order of the text blocks not the visual. Is there something in the pdf spec to flag a block of text to not be split up into separate objects?

Its makes pdf a bad format to publish programming topics in if its always getting in the way, copy/paste is unreliable, constant switching between multiple windows to try example code, its enough of a headache that printing it or buying a hardcopy is better.