Check if XWPFRun is highlighted

2019-09-10 05:25发布

For Apache POI, I am reading Word documents, both doc and docx. The old CharacterRun for doc has an isHighlighted function that tells me if text is highlighted or not. Is there an equivalent function for XWPFRun for docx files?

1条回答
forever°为你锁心
2楼-- · 2019-09-10 06:23

After a lot of research and analysis, I was able to figure out there is a function in the CTRPr class.

//p is the XWPFParagraph
for (XWPFRun pRun : p.getRuns()) {
   CTRPr ctrpr = pRun.getCTR().getRPr();
   if (ctrpr != null && ctrpr.isSetHighlight()) { 
      //This is highlighted
   }
}
查看更多
登录 后发表回答