Loading Xps from MemoryStream
A common way of loading XpsDocument is to load it from file:
XpsDocument document = new XpsDocument(filename, FileAccess.Read, CompressionOption.NotCompressed);
FixedDocumentSequence fixedDocumentSequence = document.GetFixedDocumentSequence();
//To view in the DocViewer
docViewer.Document = fixedDocumentSequence as IDocumentPaginatorSource;
But if we need to Load the Xps from a Stream we can use the Package Class and do the following:
private void LoadXpsFromStream(Byte[] xpsByte, string packageUriString)
{
MemoryStream xpsStream = new MemoryStream(xpsByte);
using (Package package = Package.Open(xpsStream))
//Remember to create URI for the package
Uri packageUri = new Uri(packageUriString);
//Need to add the Package to the PackageStore
PackageStore.AddPackage(packageUri, package);
//Create instance of XpsDocument
XpsDocument document = new XpsDocument(package, CompressionOptions.MaximuCompression, packageUriString);
//Do the operation on document here
//Here I am viewing the document in the DocViewer
FixedDocumentSequence fixedDocumentSequence = document.GetFixedDocumentSequence();
//To view in the DocViewer
docViewer.Document = fixedDocumentSequence as IDocumentPaginatorSource;
//Remember to keep the Package object in PackageStore until all operations complete on document.
//Remove the package from store
PackageStore.RemovePackage(packageUri);
doc.Close();
}
//Calling the above function from Client
//
//Get bytes[] from MemoryStream
//byte[] xpsBytes = someStream.ToArray();
//For demonstration I am reading bytes from a file
byte[] xpsBytes = File.ReadAllBytes(@"somexps.xps");
//
LoadXpsFromStream( xpsBytes, "somexps.xps");
Hope this helps.
Loading Xps from MemoryStream的更多相关文章
- xps 文件操作笔记
1. 在 Silverlight 显示XPS文件,参考:http://azharthegreat.codeplex.com/ 2. Word,Excel, PPT 文件转换为XPS: 参考一(老外写的 ...
- 步入angularjs directive(指令)--点击按钮加入loading状态
今天我终于鼓起勇气写自己的博客了,激动与害怕并存,希望大家能多多批评指导,如果能够帮助大家,也希望大家点个赞!! 用angularjs 工作也有段时间了,总体感觉最有挑战性的还是指令,因为没有指令的a ...
- 《动手实现一个网页加载进度loading》
loading随处可见,比如一个app经常会有下拉刷新,上拉加载的功能,在刷新和加载的过程中为了让用户感知到 load 的过程,我们会使用一些过渡动画来表达.最常见的比如"转圈圈" ...
- eclipse 突然 一直在loading descriptor for XXX (XXX为工程名)Cancel Requested
问题: eclipse 启动后,啥也不干,就一直在loading descriptor for XXX (XXX为工程名),,其他什么操作都不能操作. 如下图所示,保存文件也无法保存. 这个怎么办? ...
- PPT转化成Image、PPTX、XPS、EMF
最近工作经常用到演示文稿,接触到了一款不错的免费软件—Free Spire.Presentation.使用之后发现这款软件非常轻巧,功能还挺齐全.这款软件的转化功能也是非常不错的,平时遇到的各种转换难 ...
- linux使用wkhtmltopdf报错error while loading shared libraries:
官网提示 linux需要这些动态库.depends on: zlib, fontconfig, freetype, X11 libs (libX11, libXext, libXrender) 在li ...
- solr定时更新索引遇到的问题(SolrDataImportProperties Error loading DataImportScheduler properties java.lang.NullPointerException)
问题描述 报如下错误,很显然,问题原因:空指针异常: ERROR (localhost-startStop-1) [ ] o.a.s.h.d.s.SolrDataImportProperties ...
- python3: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
安装python3遇到报错: wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz ./configure --prefix=/u ...
- x01.os.21: print "Loading..."
Linux Inside 是中文版,值得下载一读. 先把目标设低点,开机进入后,在屏幕上打印“Loading..."即可.由于要在 bochs 中运行,首先就是安装 bochs.Oldlin ...
随机推荐
- python解决matplotlib中文坐标值乱码的问题
加上这句话即可 plt.rcParams['font.sans-serif']=['SimHei'] 效果:
- 服务器返回的json数据中含有null的处理方法
个人博客:http://guohuaden.com/2017/03/06/json-dataNull/因为有遇到过类似情况,所以就想到了一些解决方法,并且实践了一下,这里简单的做个记录. 注:有看到不 ...
- python中repr和eval可以用来在数据结构和字符串间互转
在这个功能上,repr和str的作用一样,把一个数据结构转换成字符串,例如: >>> str([1,2,3,4])'[1, 2, 3, 4]' >>> repr([ ...
- python3.4学习笔记(十一) 列表、数组实例
python3.4学习笔记(十一) 列表.数组实例 #python列表,数组类型要相同,python不需要指定数据类型,可以把各种类型打包进去#python列表可以包含整数,浮点数,字符串,对象#创建 ...
- C++微专业课程辅导(内存模型和动态内存)
“除了静态内存和栈内存之外,每个程序还拥有一个内存池.这部分空间被称作自由空间(free store)或堆(heap).程序用堆来存储动态分配(dynamically allocate)的对象”——& ...
- troubleshooting-windows 在 CDH集群环境读取 Hive 表 KrbException: Cannot locate default realm
KrbException: Cannot locate default realm 解决办法 1)拷贝需要组件的配置文件到项目中的 /resources/目录.如hadoop,目录/etc/hadoo ...
- 数据库 - SQLite3 中的数据类型
------------------------------ 安装 Sqlite3 和 数据库查看工具: sudo apt-get install sqlite3 sudo apt-get insta ...
- Nodejs学习笔记(四)与MySQL交互(felixge/node-mysql)
原文链接:http://www.cnblogs.com/zhongweiv/p/nodejs_mysql.html 介绍使用felixge/node-mysql进行SQL的增删改查以及断线重连等操作.
- 20145105 《Java程序设计》第10周学习总结
20145105 <Java程序设计>第10周学习总结 教材学习内容总结 JAVA网络编程 一.网络概述 (一)计算机网络概述 网络编程的实质就是两个(或多个)设备(例如计算机)之间的数据 ...
- hash-补做
题目 利用除留余数法为下列关键字集合的存储设计hash函数,并画出分别用开放寻址法和拉链法解决冲突得到的空间存储状态(散列因子取0.75) 关键字集合:85,75,57,60,65,(你的8位学号相加 ...