Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 转换为XPS的Word文件使超链接处于非活动状态_C#_Wpf_Ms Word_Xps - Fatal编程技术网

C# 转换为XPS的Word文件使超链接处于非活动状态

C# 转换为XPS的Word文件使超链接处于非活动状态,c#,wpf,ms-word,xps,C#,Wpf,Ms Word,Xps,我有一个WPF应用程序,其中我以XPS格式向用户显示word文档。 我使用Microsoft.Office.Interop.Word。代码如下 但是word文件中的超链接处于非活动状态(不可单击,也不要将我带到它们链接的位置)。我该如何解决这个问题 public static XpsDocument ConvertWordToXps(string wordFilename, string xpsFilename) { // Create a WordApplication and hos

我有一个
WPF应用程序
,其中我以
XPS
格式向用户显示
word文档
。 我使用
Microsoft.Office.Interop.Word
。代码如下

但是word文件中的超链接处于非活动状态(不可单击,也不要将我带到它们链接的位置)。我该如何解决这个问题

public static XpsDocument ConvertWordToXps(string wordFilename, string xpsFilename)
{
    // Create a WordApplication and host word document 
    var wordApp = new Application();
    wordApp.Application.Visible = false;
    wordApp.Documents.Open(wordFilename);

    // To Invisible the word document 
    wordApp.Application.Visible = false;

    // Minimize the opened word document 
    wordApp.WindowState = WdWindowState.wdWindowStateMinimize;

    Document doc = wordApp.ActiveDocument;

    doc.SaveAs(xpsFilename, WdSaveFormat.wdFormatXPS);

    var xpsDocument = new XpsDocument(xpsFilename, FileAccess.Read);
    return xpsDocument;

}

必须为处理超链接的
DocumentViewer
对象(documentviewWord)编写事件处理程序

private void link_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
    System.Diagnostics.Process.Start(e.Uri.AbsoluteUri);
}
在视图构造函数中

documentviewWord.AddHandler(Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler(link_RequestNavigate));

您是否丢失了可能导致此问题的任何格式。。如果链接显示不正确,您是否能够正确查看文档。。?此外,
超链接
被转换为
目标格式
这里是一个论坛,有一些
Q/a
我正在使用
DocumentViewer
查看XPS,它确实显示了格式正确的内容。只有超链接起作用。您的问题与此相反,它表示超链接已丢失。。请解决你的问题。我的意思是说超链接“不”起作用。嗨@coolshashi,链接没有被激活。我可以知道你是如何做到这一点的吗?