poi jar を使用して作成された docx ファイルの行数を取得する必要があります。以下のコードを使用しました
XWPFDocument doc1 = new XWPFDocument(POIXMLDocument.openPackage("LineCounter.docx"));
System.out.println("lines using method 2 --> " + doc1.getProperties().getExtendedProperties().getUnderlyingProperties().getLines());
System.out.println("word 2 --> " + doc1.getProperties().getExtendedProperties().getUnderlyingProperties().getWords());
上記のコードは、作成した docx の内容を新しいファイルにコピーした場合にのみ機能します。