diff --git a/docs-to-pdf-converter/.classpath b/docs-to-pdf-converter/.classpath index 7840a7e..e3ec8c4 100644 --- a/docs-to-pdf-converter/.classpath +++ b/docs-to-pdf-converter/.classpath @@ -50,5 +50,7 @@ + + diff --git a/docs-to-pdf-converter/libs/odfdom-java-0.8.7.jar b/docs-to-pdf-converter/libs/odfdom-java-0.8.7.jar new file mode 100644 index 0000000..60c7707 Binary files /dev/null and b/docs-to-pdf-converter/libs/odfdom-java-0.8.7.jar differ diff --git a/docs-to-pdf-converter/libs/xercesImpl-2.11.0.jar b/docs-to-pdf-converter/libs/xercesImpl-2.11.0.jar new file mode 100644 index 0000000..0aaa990 Binary files /dev/null and b/docs-to-pdf-converter/libs/xercesImpl-2.11.0.jar differ diff --git a/docs-to-pdf-converter/src/com/yeokhengmeng/docstopdfconverter/MainClass.java b/docs-to-pdf-converter/src/com/yeokhengmeng/docstopdfconverter/MainClass.java index 0a7423b..eab9c06 100644 --- a/docs-to-pdf-converter/src/com/yeokhengmeng/docstopdfconverter/MainClass.java +++ b/docs-to-pdf-converter/src/com/yeokhengmeng/docstopdfconverter/MainClass.java @@ -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; @@ -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; } @@ -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; diff --git a/docs-to-pdf-converter/src/com/yeokhengmeng/docstopdfconverter/OdtToPDF.java b/docs-to-pdf-converter/src/com/yeokhengmeng/docstopdfconverter/OdtToPDF.java new file mode 100644 index 0000000..d14725b --- /dev/null +++ b/docs-to-pdf-converter/src/com/yeokhengmeng/docstopdfconverter/OdtToPDF.java @@ -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(); + + + } + +}