/// <summary> /// Returns a new IOdfReader that can read the contents /// of the provided Odf format document. If the file format /// is not supported, then an InvalidDataException will /// be thrown. It is possible to do a pre-check using /// the IsValidFile method. /// </summary> /// <param name="path"></param> /// <returns></returns> public static IOdfReader GetNew(string path) { string extension = Path.GetExtension(path).ToUpper(); IOdfReader reader = null; if (_WordOdfExtensions.Contains(extension)) { reader = new WordReader(path); return(reader); } if (_ExcelOdfExtensions.Contains(extension)) { reader = new ExcelReader(path); return(reader); } if (_PowerPointOdfExtensions.Contains(extension)) { reader = new PowerPointReader(path); return(reader); } throw new System.IO.InvalidDataException(NOT_VALID_FILE_MESSAGE); }
public string ReadContents() { CheckInternalState(); string contents = string.Empty; if (OdfReader.IsValidFile(_InternalFilePath)) { IOdfReader reader = OdfReader.GetNew(_InternalFilePath); contents = reader.ReadContents(); } if (IsReadablePdf(_InternalFilePath)) { contents = ReadPdfContents(); } return(contents); }