I am trying to insert the following text in the document using Apache POI 3.8:
[Bold][Normal],
but the output document has this:
[Bold][Normal]
The code:
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException {
        final HWPFDocument doc = new HWPFDocument(new FileInputStream("empty.dot"));
        final Range range = doc.getRange();
        final CharacterRun cr1 = range.insertAfter("[Bold]");
        cr1.setBold(true);
        final CharacterRun cr2 = cr1.insertAfter("[Normal]");
        cr2.setBold(false);
        doc.write(new FileOutputStream("output.doc"));
    }
}
What is the correct way of doing this?
 
     
    