I'm using Apace POI 3.12 OS: Mac OS
I'm trying to create some docx word document with text from file. Text in file is cyrillic.
XWPFDocument doc = new XWPFDocument(new FileInputStream(new File("template.docx")));
XWPFRun run = doc.createParagraph().createRun();
run.setText(getTextFromFile("text.txt"));
run.setFontSize(14);
run.setFontFamily("Calibri");
where getTextFromFile(String path) - is my function and it's working, returning correct string. But when doc is generated, font style is Times New Roman, size 14. I was trying to first setFontFamily and then setText, but NPE was thrown. I've read that this NPE on setFontFamily was in apache poi 3.8 and fixed in 3.9, but seems that it's not true.
Also I've tried to put string from file to setText method and it's also not working. When text is not cyrillic, all is ok and font family is updated.
What should I do to work properly with cyrillic text?
I found the following solution, but it's not working for me: Why Apache POI XWPFRun.setFontFamily() for cyrillic works wrong?
myXWPFRun.getCTR().getRPr().getRFonts()
is null and NPE is thrown.