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

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

问题描述

这是我的代码。

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

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



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

我怎样读取它?

解决方案

我有类似的问题,使用 document.getStyles()。getDefaultRunStyle()。getFontSize();


Here is my code.

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

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

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.

How can I read it?

解决方案

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

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

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