I need to generate a PDF using Flying Saucer. Is it possible to insert EL expressions in the PDF template, load the file, pass to a EL compiler with a Map<String, Object>
as a context, and let the compiler transform the template to a compiled String, with the EL expression evaluated from the passed context? Something like this:
src/WebContent/test.xhtml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<div>Hello #{name}</div>
</body>
</html>
Java pseudocode:
Compiler compiler = new ElCompiler();
Map<String, Object> data = new HashMap<>();
data.put("name", "World!");
String template = compiler.apply("test.xhtml", data);