Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Commit

Permalink
Disable stdout when convert doc to docx
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeo Kheng Meng committed Nov 27, 2013
1 parent 229a2c0 commit 24d6f84
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion docs-to-pdf-converter/src/DocToPDFConverter.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import java.io.FileInputStream;
import java.io.OutputStream;
import java.io.PrintStream;

import org.docx4j.convert.in.Doc;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
Expand All @@ -12,7 +14,17 @@ public DocToPDFConverter(String inputFilePath, String outputFilePath) {

@Override
protected WordprocessingMLPackage getMLPackage(FileInputStream iStream) throws Exception{
WordprocessingMLPackage mlPackage = Doc.convert(iStream);
PrintStream originalStdout = System.out;

//Disable stdout temporarily as Doc convert produces alot of output
System.setOut(new PrintStream(new OutputStream() {
public void write(int b) {
//DO NOTHING
}
}));
WordprocessingMLPackage mlPackage = Doc.convert(iStream);

System.setOut(originalStdout);
return mlPackage;
}

Expand Down

0 comments on commit 24d6f84

Please sign in to comment.