01f33936 by Ean Schuessler

Add support for large PDF templates.

1 parent de5a7e1c
......@@ -35,16 +35,25 @@ public class LibreOfficeRenderer {
context.put("Linux_X86_64", "$Linux_X86_64");
context.put("Build", "$Build");
SimpleTemplateEngine engine = new SimpleTemplateEngine();
Writable stTemplate = engine.createTemplate(template).make(context);
String output = stTemplate.toString();
String output = "";
int idx = 0;
while (idx < template.length()) {
int remaining = template.length() - idx;
int chunkLength = remaining < 64000 ? remaining : 64000;
String tmplChunk = template.substring(idx, idx + chunkLength);
SimpleTemplateEngine engine = new SimpleTemplateEngine();
Writable stTemplate = engine.createTemplate(tmplChunk).make(context);
output += stTemplate.toString();
idx += chunkLength;
}
File outputFile = File.createTempFile("bfdcs-", "-tmpl");
UtilIO.writeString(outputFile, output);
List<String> args = Arrays.asList(new String[]{"libreoffice", "--headless", "--convert-to", "pdf", outputFile.getPath(), "--outdir", "/tmp"});
ProcessBuilder pb = new ProcessBuilder(args);
Map env = pb.environment();
Map<String, String> env = pb.environment();
env.put("HOME", "/home/ofbiz");
env.put("USERNAME", "ofbiz");
Process process = pb.start();
......