Font size of a paragraph empty

Hello

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.

Thank you in advance.

Jean Pascal Lim

Hi Jean,

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());

Please let us know if you have any more queries.

That’s exactly what I was looking for.
I found the line in case a style is applied but couldn’t find any way otherwise.

Thank you very much

Hi Jean,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.