Check if XWPFRun is highlighted

邮差的信 提交于 2019-12-12 02:44:23

问题


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:


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
   }
}


来源:https://stackoverflow.com/questions/33531076/check-if-xwpfrun-is-highlighted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!