WPF DocumentViewer

生成 XPS 格式

1.使用Office 2010 或者 Office 2007,单击"文件>导出>创建 PDF/XPS 文档>创建 PDF/XPS"。

 2.读取XPS文档

XAML:

<DocumentViewer x:Name="documentViewer"/>

 

C#引用:

using System.Windows.Xps.Packaging;

 

Loaded += (s, e) =>
{
    string executPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
    string xamlFilePath = System.IO.Path.Combine(executPath, "xaml", "document.xps");
    XpsDocument doc = new XpsDocument(xamlFilePath, System.IO.FileAccess.Read);
    documentViewer.Document = doc.GetFixedDocumentSequence();                
};

 

参考:https://blog.csdn.net/l550802356/article/details/128303950

posted @ 2024-06-07 12:41  microsoft-zhcn  阅读(31)  评论(0编辑  收藏  举报