mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-02-08 11:59:13 +00:00
23 lines
672 B
Java
23 lines
672 B
Java
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<String,Object> model) {
|
|
Context ctx = new Context(locale);
|
|
if (model != null) model.forEach(ctx::setVariable);
|
|
return thymeleaf.process(templateName, ctx);
|
|
}
|
|
}
|