We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to calculate no of lines on last page of docx file?

Hi There,

How can i calculate no of lines in last page of document?

@rameshce

Thanks for your inquiry. Please check “DocumentLayoutHelper” utility in Aspose.Words for .NET examples repository at GitHub. With the help of this utility, you can achieve your requirement. Please check the following code example. Hope this helps you.

Document doc = new Document(MyDir + "in.docx");
// Create a new RenderedDocument class from a Document object.
RenderedDocument layoutDoc = new RenderedDocument(doc);
Console.WriteLine(layoutDoc.Pages[doc.PageCount - 1].Columns[0].Lines.Count);

I want the solution for java (Sorry for not declaring this in question it self.) as RenderedDocument class is not available in java.

@rameshce

Thanks for your inquiry. Please check PageSplitter utility in Aspose.Words for Java examples repository at GitHub. Please use the following code example to get the desired output. Hope this helps you.

Document doc = new Document(MyDir + "in.docx");
LayoutCollector collector = new LayoutCollector(doc);
DocumentPageSplitter splitter = new DocumentPageSplitter(collector);
Document document = splitter.GetDocumentOfPage(doc.getPageCount());
System.out.println(document.getBuiltInDocumentProperties().getLines());