Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
ofbiz-directcontrolservlet
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
de2aadd0
authored
2014-11-12 15:48:27 -0600
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'BF-4364' of /home/git/repositories/brainfood/ofbiz-directcontrolservlet
2 parents
de5a7e1c
1eb9d36e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
src/com/brainfood/ofbiz/LibreOfficeRenderer.java
src/com/brainfood/ofbiz/LibreOfficeRenderer.java
View file @
de2aadd
...
...
@@ -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
();
...
...
Please
register
or
sign in
to post a comment