如何在C#中读取文件XPS? [英] how to read file XPS in C# ?

查看:113
本文介绍了如何在C#中读取文件XPS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#中读取文件XPS,请帮助我

how to read file XPS in C# , please help me

推荐答案

你可以在WPF应用程序中完成。



此代码示例只是几行代码。您可以在社区内容部分的 System.Windows.Xps.Packaging.XpsDocument 类的MSDN帮助页面的最后找到它:

http://msdn.microsoft.com/ en-us / library / system.windows.xps.packaging.xpsdocument.aspx [ ^ ]。



别忘了:你需要添加与.NET Framework v.3.5及更高版本捆绑在一起的程序集ReachFramework.DLL的引用,因此请从添加引用窗口的.NET选项卡中添加它。



这个想法是:

You can do it in a WPF application.

This code sample is just few lines of code. You can find it here, at the very end of the MSDN help page on the class System.Windows.Xps.Packaging.XpsDocument in the section "Community Content":
http://msdn.microsoft.com/en-us/library/system.windows.xps.packaging.xpsdocument.aspx[^].

Don''t forget: you need to add the reference to the assembly "ReachFramework.DLL" which is bundled with .NET Framework v.3.5 and later, so add it from the ".NET" tab of the window "Add Reference".

The idea is:
//assuming this is the file name of some XPS document:
string fileName; //assign appropriate path name to it, from file dialog, for example

System.Windows.Controls.DocumentViewer viewer; //should be initialized and inserted in UI

//...

System.Windows.Xps.Packaging.XpsDocument doc =
    new System.Windows.Xps.Packaging.XpsDocument(fileName, System.IO.FileAccess.Read);
viewer.Document = doc.GetFixedDocumentSequence(); //viewing it!



它有效,测试。



-SA


这篇关于如何在C#中读取文件XPS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆