de2aadd0 by Adam Heath

Merge branch 'BF-4364' of /home/git/repositories/brainfood/ofbiz-directcontrolservlet

2 parents de5a7e1c 1eb9d36e
......@@ -35,16 +35,24 @@ public class LibreOfficeRenderer {
context.put("Linux_X86_64", "$Linux_X86_64");
context.put("Build", "$Build");
StringBuilder output = new StringBuilder();
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(template).make(context);
String output = stTemplate.toString();
Writable stTemplate = engine.createTemplate(tmplChunk).make(context);
output.append(stTemplate.toString());
idx += chunkLength;
}
File outputFile = File.createTempFile("bfdcs-", "-tmpl");
UtilIO.writeString(outputFile, output);
UtilIO.writeString(outputFile, output.toString());
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();
ProcessBuilder pb = new ProcessBuilder("libreoffice", "--headless", "--convert-to", "pdf", outputFile.getPath(), "--outdir", outputFile.getParentFile().getPath());
Map<String, String> env = pb.environment();
env.put("HOME", "/home/ofbiz");
env.put("USERNAME", "ofbiz");
Process process = pb.start();
......