I would like to know how can I get back the font size of a Paragraph which is empty (ie. doesn’t contain anything). I can’t find any method which provides me such information.
I provide a file with an example of a line whom size is specific but remains empty.
Thanks for your inquiry. To get the font size of an empty paragraph which has no runs, please use the following code snippet. If a style is applied to an empty paragraph (no child nodes), you can also get font size by Style.getFont().getSize().
//Open document
Document doc = new Document(MyDir + "test (1).docx");
DocumentBuilder builder = new DocumentBuilder(doc);
Paragraph para = (Paragraph)doc.getChild(NodeType.PARAGRAPH, 1, true);
// Move the cursor to empty paragraph
builder.moveTo(para);
// Get the size of empty paragraph
System.out.println(builder.getFont().getSize());
// If style is applied to paragraph, you can get the font size by Style.getFont().getSize()
System.out.println(para.getParagraphFormat().getStyle().getFont().getSize());