Free Support Forum - aspose.com

Invalid font names

Hi, can you look at the attached document. I am getting invalid font name on Run.
Here is the code snippet:
InputStream inputStream = getClass().getClassLoader()
.getResourceAsStream(testDoc);

Document document = new Document(inputStream);

DocumentBuilder builder = new DocumentBuilder(document);

Node node = getCell(document).getNode();

out.println(node.getText());

Run run = (Run) node;

out.println(run.getFont().getName()); // returns Wingdings

builder.moveTo(run);

out.println(builder.getFont().getName()); // returns Wingdings

private NodeWrapper getCell(Document document) throws Exception {
final NodeWrapper nodeWrapper = new NodeWrapper();

document.accept(new DocumentVisitor() {
private boolean found = false;

@Override
public int visitRun(Run arg0) throws Exception {
String runText = arg0.getText();

if (runText.contains(String.valueOf(’\uF06F’)) && !found) {
found = true;

nodeWrapper.setNode(arg0);
}

return super.visitRun(arg0);
}

});

return nodeWrapper;
}

You can see that returned font names are Wingdings, but in word document they are Arial.

Thanks, Ivica.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. In your document you have symbols “o”. Font of this symbol is “Wingdings”. Just double click on this symbol and you will see that.

Best regards.