private void BtnDoc_Click(object sender, RoutedEventArgs e) { SaveFileDialog fileDialog = new SaveFileDialog(); Person person = new Person(); string path = person.FilePath; fileDialog.Filter = "Text documents (.doc)|*.doc"; fileDialog.Title = "Save an Doc File"; if (fileDialog.ShowDialog() == true) { string fileName = fileDialog.FileName; string extesion = System.IO.Path.GetExtension(fileName); switch (extesion) { case ".doc": //do something here Spire.Doc.Document document = new Spire.Doc.Document(); document.LoadText(path); document.SaveToFile(fileName, FileFormat.Doc); document.Close(); MessageBox.Show("Conversion Successful...."); break; } } /* * document.SaveToFile(System.IO.Path.Combine(path, "TestWordDoc.docx"), FileFormat.Doc); * document.LoadFromFile(System.IO.Path.Combine(path, "TestTxt.txt")); * * document.LoadFromFile(System.IO.Path.Combine(docPath, "TestWordDoc.docx")); * string readText = File.ReadAllText(System.IO.Path.Combine(docPath, "TestTxt.txt")); */ }
private void BtnPdf_Click(object sender, RoutedEventArgs e) { SaveFileDialog fileDialog = new SaveFileDialog(); Person person = new Person(); string path = person.FilePath; string imgPath = person.ImagePath; fileDialog.Filter = "Text documents (.pdf)|*.pdf"; fileDialog.Title = "Save an Pdf File"; if (fileDialog.ShowDialog() == true) { string fileName = fileDialog.FileName; string extesion = System.IO.Path.GetExtension(fileName); switch (extesion) { case ".pdf": Spire.Doc.Document document = new Spire.Doc.Document(); document.LoadText(path); document.SaveToFile(fileName, FileFormat.PDF); document.Close(); MessageBox.Show("Conversion Successful...."); break; } } // this.Close(); }