Search code examples
javaspringspring-bootpdfthymeleaf

Does Thymeleaf support flexbox?


I have a Java/SpringBoot service that is using Thymeleaf to assemble HTML and CSS fragments from other locations into a PDF document. I have noticed that the CSS that I am inlining into the document uses Flexbox properties: display: flex. However, it appears these CSS rules are not obeyed by Thymeleaf. Does Thymeleaf have support for Flexbox and CSS3 features?

<head>
  <style th:inline="text">
      [(${css})]
  </style>
</head>

Solution

  • OK, I figured this out.

    Short answer: I'm an idiot.

    Long answer: The problems I was facing were directly related to the Flying Saucer library. I'm using Thymeleaf to template and render my HTML, then handing that over to Flying Saucer to produce the PDF. Flying Saucer has limited documentation and they do not play nicely with CSS3 features (flexbox, transforms, etc.). Once I reverted my HTML to using CSS2 (hello Tables and images!) things started to render correctly.