0

Pretty straightforward question. Anyone knows the combination of method calls? Are there any manual methods to get the start and end lines of document elements? Maybe by calculating offsets (if getting offset values are possible). Thanks!

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
Ram
  • 1,016
  • 4
  • 15
  • 25
  • Are you aware that the Word file format is neither page based nor line based file format? And so largely that information isn't stored in them? – Gagravarr Nov 27 '13 at 22:40
  • @Gagravarr Yes, I think it is XML based. Was just asking if there is anyway to compute the line numbers. – Ram Nov 28 '13 at 02:40

1 Answers1

2

In order to get the number of lines of a document, assuming you've got a XWPFDocument document already instantiated:

ExtendedProperties ep = document.getProperties().getExtendedProperties();
int numberOfLines = ep.getUnderlyingProperties().getLines());

Since XWPFParagraph also gives you an XWPFDocument corresponding to that paragraph, you can also extract number of lines from there.