Merge branch 'BF-4364' of /home/git/repositories/brainfood/ofbiz-directcontrolservlet
Showing
1 changed file
with
15 additions
and
7 deletions
... | @@ -35,16 +35,24 @@ public class LibreOfficeRenderer { | ... | @@ -35,16 +35,24 @@ public class LibreOfficeRenderer { |
35 | context.put("Linux_X86_64", "$Linux_X86_64"); | 35 | context.put("Linux_X86_64", "$Linux_X86_64"); |
36 | context.put("Build", "$Build"); | 36 | context.put("Build", "$Build"); |
37 | 37 | ||
38 | SimpleTemplateEngine engine = new SimpleTemplateEngine(); | 38 | StringBuilder output = new StringBuilder(); |
39 | Writable stTemplate = engine.createTemplate(template).make(context); | 39 | int idx = 0; |
40 | String output = stTemplate.toString(); | 40 | |
41 | while (idx < template.length()) { | ||
42 | int remaining = template.length() - idx; | ||
43 | int chunkLength = remaining < 64000 ? remaining : 64000; | ||
44 | String tmplChunk = template.substring(idx, idx + chunkLength); | ||
45 | SimpleTemplateEngine engine = new SimpleTemplateEngine(); | ||
46 | Writable stTemplate = engine.createTemplate(tmplChunk).make(context); | ||
47 | output.append(stTemplate.toString()); | ||
48 | idx += chunkLength; | ||
49 | } | ||
41 | 50 | ||
42 | File outputFile = File.createTempFile("bfdcs-", "-tmpl"); | 51 | File outputFile = File.createTempFile("bfdcs-", "-tmpl"); |
43 | UtilIO.writeString(outputFile, output); | 52 | UtilIO.writeString(outputFile, output.toString()); |
44 | 53 | ||
45 | List<String> args = Arrays.asList(new String[]{"libreoffice", "--headless", "--convert-to", "pdf", outputFile.getPath(), "--outdir", "/tmp"}); | 54 | ProcessBuilder pb = new ProcessBuilder("libreoffice", "--headless", "--convert-to", "pdf", outputFile.getPath(), "--outdir", outputFile.getParentFile().getPath()); |
46 | ProcessBuilder pb = new ProcessBuilder(args); | 55 | Map<String, String> env = pb.environment(); |
47 | Map env = pb.environment(); | ||
48 | env.put("HOME", "/home/ofbiz"); | 56 | env.put("HOME", "/home/ofbiz"); |
49 | env.put("USERNAME", "ofbiz"); | 57 | env.put("USERNAME", "ofbiz"); |
50 | Process process = pb.start(); | 58 | Process process = pb.start(); | ... | ... |
-
Please register or sign in to post a comment