prawnpdf / prawn

Fast, Nimble PDF Writer for Ruby
https://prawnpdf.org
Other
4.68k stars 688 forks source link

Support for line numbers? #1213

Closed rhwood closed 3 years ago

rhwood commented 3 years ago

It seems there no support line numbering (ideally every N lines). Is that correct?

If that is correct, can line numbering be added?

I am thinking this based on comments in asciidoctor/asciidoctor-pdf#636

gettalong commented 3 years ago

Adding line numbering to Prawn in a general way would be difficult due to the way Prawn generates documents.

Prawn has no complete implicit notion of line order. There is the cursor which goes down the page and when you print some text, it may consist of multiple lines. But nowhere does it store how many lines went before. So you would need to keep track of that yourself.

There are also other problems: How would you handle tables or text in columns?

I gather Word and Writer have it easier because they have the concepts of a document with paragraphs, headers, ... split into multiple pages.

Therefore I will close the issue but we are open to pull requests if someone wants to try their hand on this.