I want to creating new Word document from a model document (.docx) and replace some text with styling.
How can I style the firstName in Bold and message as yellow highlight color?
My Code is below:
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(templateInputStream);
MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
VariablePrepare.prepare(wordMLPackage);
HashMap<String, String> variables = new HashMap<>();
variables.put("firstName", "fileName123");
variables.put("lastName", "lastName345");
variables.put("message", "messsssssss");
documentPart.variableReplace(variables);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
wordMLPackage.save(outputStream);
return outputStream.toByteArray();
A screenshot of my starting model [sic: template] docx is shown below:
A screenshot of my expected result is the following:

