Encontrei a seguinte resposta sobre sua pergunta. De acordo com o segundo parágrafo, é quase impossível fazer o que você quer.
Resposta do usuário grantm em 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.