views:

56

answers:

2

I am writing a little bit of documentation and code explanation. I would like to copy code from eclipse including line numbers, so that it becomes easier to reference the code in the text.

Is there any way to do this in eclipse or some other IDE, editor?

+1  A: 

You can do it by printing a PDF of source file, then copying source with line numbers from the PDF document.

It works for me with eclipse PDT + CutePDF, it should also work with Acrobat PDF printer

Benoit
Fantastic, works with PDFCreator. It does not preserve indentation, when i paste it into my editor but that is only a minor issue.
mrt181
I haven't noticed that, it could be due to PDF cell formatting... sorry
Benoit
+2  A: 

Since Eclipse 3.4 and bug 19602, you will print the line numbers if you have activated them on the Eclipse editor.

alt text

Printing a source will give you:

alt text

VonC