简体   繁体   中英

How to set text hightlight using Apache POI PPT API?

I'm using apache poi to process ppt.I can get the CTTextCharacterProperties of a CTRegularTextRun by using method CTRegularTextRun's getRPr(),and then I can find a method setHighlight(CTColor var1) in interface CTTextCharacterProperties,but I don't know how to make text content being highlighted.does anyone can help me?

CTTextParagraph paragraph=new CTTextParagraph();
List<CTRegularTextRun> rList = paragraph.getRList();
for(CTRegularTextRun run:rList){
   CTTextCharacterProperties rPr=run.getRPr();
   CTColor ctColor=rPr.isSetHighlight()==true?rPr.getHighlight():rPr.addNewHighlight();
   CTSRgbColor srgbClr=ctColor.isSetSrgbClr()==true?ctColor.getSrgbClr():ctColor.addNewSrgbClr();
   byte[] rgbBytes = {(byte) Color.GREEN.getRed(), (byte) Color.GREEN.getGreen(), (byte) Color.GREEN.getBlue()};
   srgbClr.setVal(rgbBytes);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM