[Java] Line numbers in a document

I can’t find example or how to get the current line number while I am creating the MS Word file. And the

doc.getBuiltInDocumentProperties().getLines() method returns wrong number. 

The documents might be signed, so I don’t want to change the format if possible.
Is there some workaround ?

Best regards,
speedyGonzales



Hi Yoncho,

Thanks for your inquiry. Please note that MS Word
document is flow document and does not contain any information about
its layout into lines and pages. Therefore, technically there is no
“Page”
and “Line” concept in Word document.

Aspose.Words uses our own Rendering Engine to layout documents into pages and lines. Please check the attached DocumentLayoutHelper sample. This sample demonstrates how to easily work with the layout elements of
a document and access the pages, lines, rows, spans etc.
SpeedyGonzales:

doc.getBuiltInDocumentProperties().getLines() method returns wrong number.

Could you please attach your input Word document here for testing? I will investigate the issue on my side and provide you more information.

Ok, I will see and test your suggestion on my side. Here is a sample document I created to do some tests. I want to be able to get the lines inside the table too. Instead of 14, the line count is 5. Here is some code.

public class LineNumberTest {


public void testLines(){
Document doc=null;
try {
doc = new Document( “~\LineCountTest.docx”);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

BuiltInDocumentProperties props = doc.getBuiltInDocumentProperties();
for(DocumentProperty p: props){
System.out.println(p.getName()+" "+p.getValue());
}
}

public static void main(String[] args) {
LineNumberTest test=new LineNumberTest();
test.testLines();
}

}

Hi Yoncho,

Thanks for sharing the detail. I have tested the scenario and have managed to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-10909. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

SpeedyGonzales:

I want to be able to get the lines inside the table too.

I suggest you please check the attached “documentLayoutHelper
example project. This sample demonstrates how to easily work with the
layout elements of a document and access the pages, lines, spans etc.
Hope this helps you. Please let us know if you have any more queries.

The issues you have found earlier (filed as WORDSNET-10909) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

A post was split to a new topic: Get line count of specific page of document