How set bold for docx run apache poi

How set bold for run with run.getCTR().getRPr()? I write this code but it doesn't work at all.


I had the same problem with font-size but I fixed it with this code:

CTHpsMeasure size = CTHpsMeasure.Factory.newInstance();
sizeFa.setVal(new BigInteger((sizePoint * 2) + ""));

Now I want to set bold with code like above, with getCTR(). what should I do? Thanks.

1 answer

  • answered 2017-09-23 13:46 Axel Richter

    If run.getCTR().getRPr().setSzCs(size); is needed for you to set the font size, then you are using Complex Script (Cs) characters. That might be characters of special bidirectional (right to left) language (arabic for example).

    So for bold you should try using CTRPr.setBCs.

    import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
    import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
      CTOnOff ctonoff = CTOnOff.Factory.newInstance();