← Home
Success Story · Kotlin · Java · Spring Boot · AWS

PDF generation in microservice landscapes

A client wanted to extend their microservice landscape with PDF generation and distribution – multilingual, without costly deployments and without licensing pitfalls.

Challenge

Generate and distribute PDF documents – integrated into the client’s existing AWS landscape.

Solution

A dedicated microservice renders PDFs from HTML templates with Thymeleaf, Flying Saucer and OpenPDF and is connected via REST.

Result

Templates and translations can be swapped without a deployment – with building blocks licensed for commercial use.

Technology

HTML in, PDF out

The project uses Flying Saucer to turn HTML into PDF. Underneath, either iText 5 or OpenPDF can serve as the PDF library – the resulting documents are identical in size and appearance.

The recommendation was OpenPDF: it is licensed under the LGPL and can be used in commercial environments without issues. In addition, the Flying Saucer team ended support for iText 5 in May 2024.

Integration

Swap without deploying

A key requirement: change PDF templates and translations without redeploying every time.

  • A dedicated microservice handles PDF generation.
  • It connects to the existing AWS landscape via REST interfaces.
  • HTML templates and translations live in a database and are loaded dynamically.
Fonts

The underestimated licensing question

The font embedded in the PDFs needs special attention – especially for other scripts such as Cyrillic. Popular fonts like Arial require a license and can cause considerable costs.

The solution: the free Noto font family. It supports more than 800 languages and may be redistributed freely under the SIL Open Font License.

Prototype

Up and running on GitHub

A working prototype is publicly available on GitHub. It delivers PDFs synchronously and can easily be adapted for asynchronous distribution.

  • Java 21
  • Kotlin
  • Spring Boot
  • Spring Data
  • Hibernate
  • PostgreSQL
  • Docker
  • Docker Compose
  • Testcontainers
  • Rest Assured
  • JUnit
  • Maven
Contact

Let’s talk about your backend.

Drop me a short note about what you need. I’ll get back to you personally, and together we’ll find out whether and how I can help.

Portrait of Christoph Sens
Christoph SensYour direct point of contact