如何在 Apache POI(java) 中读取 .docx 中的字体大小和字体名称 [英] How to read font size and font name in .docx in Apache POI(java)

查看:42
本文介绍了如何在 Apache POI(java) 中读取 .docx 中的字体大小和字体名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码.

XWPFRun run = runlist.get(0);
double fontsize = (double)(run.getFontSize());
String fontfamily = (String)run.getFontFamily();

当它读取 .docx 文件时,它有时会在字体大小中返回 -1,在字体系列中返回 null.

When it read the .docx file it will sometimes return -1 in font size and null in font family.

我知道这是因为它们是默认值,但我不想要 -1 和 null,我只想要该默认值的名称.

I know that it's because they are default value but I don't want -1 and null I just want the name of that default value.

如何阅读?

推荐答案

我遇到了类似的问题,我用 document.getStyles().getDefaultRunStyle().getFontSize();

I had a similar problem and I got it fixed with document.getStyles().getDefaultRunStyle().getFontSize();

这篇关于如何在 Apache POI(java) 中读取 .docx 中的字体大小和字体名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆