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
01f33936
authored
2014-11-10 17:43:04 -0600
by
Ean Schuessler
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add support for large PDF templates.
1 parent
de5a7e1c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
src/com/brainfood/ofbiz/LibreOfficeRenderer.java
src/com/brainfood/ofbiz/LibreOfficeRenderer.java
View file @
01f3393
...
...
@@ -35,16 +35,25 @@ public class LibreOfficeRenderer {
context
.
put
(
"Linux_X86_64"
,
"$Linux_X86_64"
);
context
.
put
(
"Build"
,
"$Build"
);
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
(
template
).
make
(
context
);
String
output
=
stTemplate
.
toString
();
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
();
...
...
Please
register
or
sign in
to post a comment