I have an application built on Spring MVC that reads a MSWord DOCX with Apache POI and returns it to a HTML Thymeleaf web page. But I am not able to maintain the text formatting styles like bold, italic, font-color, font-size, etc.
The Spring Controller method returns a ModelAndView with a variable called docDetail loaded with a XWPFDocument object from loadResource().
[...]
@GetMapping("/document")
public ModelAndView document() {
[...]
modelAndView.addObject("docDetail", fileService.loadResource());
return modelAndView;
}
[...]
The HTML Thymeleaf fills a fragment while iterate over the paragraphs from the document.
[...]
<div th:fragment="doc-detail">
<div th:each="par : ${docDetail.paragraphs}">
<p th:text="${par.text}"></p>
</div>
</div>
[...]
And the result appears as plain text. I have not tried Apache Tika yet. So, How can I keep the styles from the document to the web page? Thanks in advance.
fileServicein the controller? Specifically, the POI parts?