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

Commit

Permalink
Added ODT support
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeo Kheng Meng committed Nov 28, 2013
1 parent d7cd9d9 commit f58ccd7
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs-to-pdf-converter/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,7 @@
<classpathentry kind="lib" path="libs/args4j-2.0.21.jar"/>
<classpathentry kind="lib" path="libs/ooxml-schemas-1.1.jar"/>
<classpathentry kind="lib" path="libs/poi-ooxml-3.9.jar"/>
<classpathentry kind="lib" path="libs/odfdom-java-0.8.7.jar"/>
<classpathentry kind="lib" path="libs/xercesImpl-2.11.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file added docs-to-pdf-converter/libs/odfdom-java-0.8.7.jar
Binary file not shown.
Binary file added docs-to-pdf-converter/libs/xercesImpl-2.11.0.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
public class MainClass{


public static final String VERSION_STRING = "\nDocs to PDF Converter Version 1.2 (28 Nov 2013)\n\nThe MIT License (MIT)\nCopyright (c) 2013-2014 Yeo Kheng Meng";
public static final String VERSION_STRING = "\nDocs to PDF Converter Version 1.3 (28 Nov 2013)\n\nThe MIT License (MIT)\nCopyright (c) 2013-2014 Yeo Kheng Meng";
public enum DOC_TYPE {
DOC,
DOCX,
PPT,
PPTX
PPTX,
ODT
}

private static PrintStream originalStdout = null;
Expand Down Expand Up @@ -87,15 +88,19 @@ public static Converter processArguments(String[] args) throws IllegalArgumentEx
}


String lowerCaseInPath = inPath.toLowerCase();

if(values.type == null){
if(inPath.endsWith("doc")){
if(lowerCaseInPath.endsWith("doc")){
converter = new DocToPDFConverter(inPath, outPath);
} else if (inPath.endsWith("docx")){
} else if (lowerCaseInPath.endsWith("docx")){
converter = new DocxToPDFConverter(inPath, outPath);
} else if(inPath.endsWith("ppt")){
} else if(lowerCaseInPath.endsWith("ppt")){
converter = new PptToPDFConverter(inPath, outPath);
} else if(inPath.endsWith("pptx")){
} else if(lowerCaseInPath.endsWith("pptx")){
converter = new PptxToPDFConverter(inPath, outPath);
} else if(lowerCaseInPath.endsWith("odt")){
converter = new OdtToPDF(inPath, outPath);
} else {
converter = null;
}
Expand All @@ -112,6 +117,8 @@ public static Converter processArguments(String[] args) throws IllegalArgumentEx
break;
case PPTX: converter = new PptxToPDFConverter(inPath, outPath);
break;
case ODT: converter = new OdtToPDF(inPath, outPath);
break;
default: converter = null;
break;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.yeokhengmeng.docstopdfconverter;

import java.io.FileInputStream;
import java.io.FileOutputStream;

import org.odftoolkit.odfdom.converter.pdf.PdfConverter;
import org.odftoolkit.odfdom.converter.pdf.PdfOptions;
import org.odftoolkit.odfdom.doc.OdfTextDocument;


public class OdtToPDF extends Converter {

public OdtToPDF(String inputFilePath, String outputFilePath) {
super(inputFilePath, outputFilePath);
}

@Override
public void convert() throws Exception {
startTime();
showLoadingMessage();

FileInputStream inStream = getInFileStream();
OdfTextDocument document = OdfTextDocument.loadDocument(inStream);

PdfOptions options = PdfOptions.create();
FileOutputStream out = getOutFileStream();

showProcessingMessage();
PdfConverter.getInstance().convert(document, out, options);

showFinishedMessage();


}

}

0 comments on commit f58ccd7

Please sign in to comment.