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 ...
随机推荐
- 聊聊WKWebView
聊一聊WKWebView 前言 由于之前一直在用UIWebView,所以对于WKWebView只是停留在知道,了解的状态,并未深入的去研究.前天一个项目要求支持iOS8以上,要加入一个web界面.在习 ...
- 让360双核浏览器默认极速模式,避免采用IE模式无法正常访问html5网页的解决办法
让360双核浏览器默认极速模式,避免采用IE模式无法正常访问html5网页的解决办法 用Meta标签代码让360双核浏览器默认极速模式不是兼容模式<meta name="rendere ...
- django session 使用案例
django session 使用案例 HTTP被设计为”无状态”,每次请求都处于相同的空间中. 在一次请求和下一次请求之间没有任何状态保持,我们无法根据请求的任何方面(IP地址,用户代理等)来识别来 ...
- Django 搭建后台 favicon.ico 文件操作
Django 搭建后台 favicon.ico 文件操作 使用 django 搭建后台服务器,我用的是 django 1.8 版本以上的,就是路由不是 url 而是 path 的,这里有一个关于fav ...
- 20145101 《Java程序设计》第7周学习总结
20145101<Java程序设计>第7周学习总结 教材学习内容总结 第十二章 Lambda Lambda表达式中this的参考对象以及toString()的接受者,是来自Lambda的周 ...
- 20145118《Java程序设计》 第7周学习总结
20145118<Java程序设计> 第7周学习总结 教材学习内容总结 本周学习内容为第十三章,以下为教材内容重点总结: 1.格林威治标准时间简称GMT时间. 2.java.util.Da ...
- 20145225唐振远《网络对抗》 Web安全基础实践
20145225唐振远<网络对抗>Web安全基础实践 参考博客:20145215 卢肖明 基础问题回答 (1)SQL注入攻击原理,如何防御? SQL注入攻击就是通过把SQL命令插入到Web ...
- CEF之CefSettings设置locale
参考:https://blog.csdn.net/xiezhongyuan07/article/details/84402083 在开发过程遇到一个问题,CEF加载一个静态页面,然后在静态页面上有一个 ...
- How can I list all foreign keys referencing a given table in SQL Server?
How can I list all foreign keys referencing a given table in SQL Server? how to check if columns in ...
- 【Map】Echarts之iphone销量地图的使用以及详细配置
1.引入echarts库文件 <script charset="utf-8" type="text/javascript" language=" ...