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

Free Support Forum - aspose.com

How to get font information of each word/span using Java API

I find out that I can get font information by searching for each Run object in a document. My code:

NodeCollection<Run> runs = document.getChildNodes(NodeType.RUN, true);
for (Run run : runs) {
      System.out.println("color: " + run.getFont().getColor());
      System.out.println("size: " + run.getFont().getSize());

Using this approach, I can get font information of a Run object, which should be part of a paragraph. But how can I get the font information for each word/span in the paragraph?


Please note that all text of Word document is stored in runs of text. E.g. following text can be in a single Run node or multiple Run nodes.

How to get font information

The same case is with each word in the document e.g. word How can be in single or multiple Run nodes.

Could you please ZIP and attach your input Word document along with expected output? We will then provide you more information about your query.

Formats.docx (12.3 KB)

I uploaded an input file. We want to match each word to the run object it belongs to. Is there an easy way to do it?


Could you please share your expected output for this Word document? We will then provide you code example according to your requirement.