Как установить цвет фона (цвет страницы) для документа Word (.doc или .docx) в Java?
Некоторые библиотеки, такие какhttp://poi.apache.org мы могли бы создатьдокумент Word с любым цветом текста, но дляфон или выделение текста, я не нашел никакого решения.
Цвет страницы для слова ручным способом !:
Вот мой основной код для создания текстового документа от poi.apache
// Blank Document
@SuppressWarnings("resource")
XWPFDocument document = new XWPFDocument();
// Write the Document in file system
FileOutputStream out = new FileOutputStream(new File(file_address));
// create Paragraph
XWPFParagraph paragraph = document.createParagraph();
paragraph.setAlignment(ParagraphAlignment.RIGHT);
XWPFRun run = paragraph.createRun();
run.setFontFamily(font_name);
run.setFontSize(font_size);
// This only set text color not background!
run.setColor(hex_color);
for (String s : text_array) {
run.setText(s);
run.addCarriageReturn();
}
document.write(out);
out.close();