package com.imprimelibros.erp.pdf; import org.thymeleaf.context.Context; import org.thymeleaf.spring6.SpringTemplateEngine; import org.springframework.stereotype.Service; import java.util.Locale; import java.util.Map; @Service public class PdfTemplateEngine { private final SpringTemplateEngine thymeleaf; public PdfTemplateEngine(SpringTemplateEngine thymeleaf) { this.thymeleaf = thymeleaf; } public String render(String templateName, Locale locale, Map model) { Context ctx = new Context(locale); if (model != null) model.forEach(ctx::setVariable); return thymeleaf.process(templateName, ctx); } }