Erwin Alcantara

Erwin Alcantara

  • NA
  • 18
  • 1.4k

w can I unload xps file in documentviewer

Sep 30 2019 5:51 PM
  1. private XpsDocument ConvertWordDocToXPSDoc(string wordDocName, string xpsDocName) {    
  2.  // Create a WordApplication and add Document to it    
  3.  Microsoft.Office.Interop.Word.Application    
  4.  wordApplication = new Microsoft.Office.Interop.Word.Application();    
  5.  wordApplication.Documents.Add(wordDocName);    
  6.  Document doc = wordApplication.ActiveDocument;    
  7.  try {    
  8.   doc.SaveAs(xpsDocName, WdSaveFormat.wdFormatXPS);    
  9.   wordApplication.Quit();    
  10.   XpsDocument xpsDoc = new XpsDocument(xpsDocName, FileAccess.ReadWrite);    
  11.   return xpsDoc;    
  12.  } catch (Exception exp) {    
  13.   string str = exp.Message;    
  14.  }    
  15.  return null;    
  16. }    
  17. private void LoadMyreminder() {    
  18.  string XPSMyReminder = String.Concat(Path.GetDirectoryName(_myReminder), "\\",    
  19.   Path.GetFileNameWithoutExtension(_myReminder), ".xps");    
  20.  myRemviewer.Document = ConvertWordDocToXPSDoc(    
  21.   _myReminder,    
  22.   XPSMyReminder).GetFixedDocumentSequence();    
  23. }    
  24. private void BtnEditMyrem_Click(object sender, RoutedEventArgs e) {    
  25.  Microsoft.Office.Interop.Word.Application ap = new Microsoft.Office.Interop.Word.Application {    
  26.   Visible = true    
  27.  };    
  28.  Document document = ap.Documents.Open(_myReminder);    
  29. }  

Answers (1)