WPF 和 XPS:空文档查看器
byte[] mediaBytes = Convert.FromBase64String("<<strings>>");
XpsDocument doc;
ms = new MemoryStream(mediaBytes, 0, mediaBytes.Length);
Uri DocumentUri = new Uri("pack://document.xps");
using (Package package = Package.Open(ms, FileMode.Create))
{
PackageStore.AddPackage(DocumentUri, package);
doc = new XpsDocument(package, CompressionOption.Maximum, DocumentUri.AbsoluteUri);
FixedDocumentSequence fds = doc.GetFixedDocumentSequence();
documentViewer.Document = fds as IDocumentPaginatorSource;
PackageStore.RemovePackage(DocumentUri);
doc.Close();
}
任何人都可以帮助我吗?其结果是一个空文档。 mediaBytes 是一个 PDF 文档。
byte[] mediaBytes = Convert.FromBase64String("<<strings>>");
XpsDocument doc;
ms = new MemoryStream(mediaBytes, 0, mediaBytes.Length);
Uri DocumentUri = new Uri("pack://document.xps");
using (Package package = Package.Open(ms, FileMode.Create))
{
PackageStore.AddPackage(DocumentUri, package);
doc = new XpsDocument(package, CompressionOption.Maximum, DocumentUri.AbsoluteUri);
FixedDocumentSequence fds = doc.GetFixedDocumentSequence();
documentViewer.Document = fds as IDocumentPaginatorSource;
PackageStore.RemovePackage(DocumentUri);
doc.Close();
}
Can anyone please help me. Its result is an empty document. The mediaBytes is a PDF document.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的声明中: Package package = Package.Open(ms, FileMode.Create)
您将 ms 设置为包目标流,而不是源流。
In your statement: Package package = Package.Open(ms, FileMode.Create)
You are setting ms as the package destination stream, not a source stream.