Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Would it be possible to show line numbers as part of the pdf document. What option should I use?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I've found the following answer regarding your question. According to the second paragraph, it's almost impossible to do what you want.

Answer by user grantm on perlmonks.org:

It may be possible - it depends on how the PDF was generated. If the option was used to convert text to curves then you're probably out of luck.

Also the PDF file format has no concept of 'lines'. Characters in a particular font family, weight, size (etc) are placed at X/Y coordinates on the page. They can be placed in any order (ie: not just left-right, top to bottom).

So if it were possible, one approach would be to find the y coordinate of every piece of text on the page; reduce that to a unique set; sort them and assign line numbers; go down and add the line numbers as text elements at the same y coordinate on the right hand side of the page.

For the first part, you might find that the CAM::PDF module has some useful tools (eg: it can render just the text elements of a PDF page). Overlaying new text elements is the easy part. I tend to use PDF::Reuse but I'm sure that PDF::API2 could be used too.

share|improve this answer
    
It's possible to view line numbers on a text file if you view it via an editor, I am just looking for a similar capability –  Joshua Jul 7 '11 at 11:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.