This document describes the pros and cons of different java PDF generation libraries and select the one that best fits our need.

Library

Apache FOB

Jasper Report

Open HTML to PDF

Thymeleaf + Flying Saucer

Pros

  • use standard XSL-FO for styling

  • rich output formats, including PDF, TXT, PNG and the rest

  • mature community and rich documents

  • mature editors to view and edit XSL-FO

  • use JRXML for both content and styling/layout

  • rich output formats

  • mature community and rich documents

  • mature editors to view and edit JRXML

  • support placeholders and related features

  • use HTML and CSS to represent both content and styling/layout

  • mature community

  • can be edited and previewed with a lot of text editors and browsers

  • support placeholders and related features

  • use HTML and CSS to represent both content, layout and styling

  • mature community

  • ca be edited and previewed with a lot of text editors and browsers

  • support placeholders and specific expressions

  • rich output formats

Cons

  • separated definitions of output content and styling, making it difficult to edit and preview visually

  • doesn’t support placeholders natively; developers have to implement features to replace placeholders

  • JRXML is not a common standard, but it’s not a big problem

  • only support PDF output

Outcome

Jasper report is the best fit in the long run, but currently since we only need to generate statements/documents of single transactions, so Thymeleaf + Flying Saucer is the choice.