[英]XpsDocument GetFixedDocumentSequence return null for files generated by a specific computer
[英]XpsDocument GetFixedDocumentSequence return null
我像這樣從打印機讀取數據:
using (Stream stream = client.GetStream())
{
using (MemoryStream ms = new MemoryStream())
{
stream.CopyTo(ms);
client.Close();
byte[] result = ms.ToArray();
...
using (var memoryStream = new MemoryStream(result))
{
using (var package = Package.Open(memoryStream, FileMode.Open))
{
var packageUri = new Uri("memorystream://printstream");
PackageStore.AddPackage(packageUri, package);
var xpsDocument = new XpsDocument(package, CompressionOption.Fast, packageUri.OriginalString);
return xpsDocument.GetFixedDocumentSequence() // NULL
我也嘗試將流直接保存到文件中,然后讀取為File.ReadAllBytes(filePath),但結果是相同的。
將流保存到文件后,可以通過XpsViewer毫無問題地打開它。
奇怪,但是正在工作。 我必須使用XpsConverter.exe並將.xps文件轉換為.xps。 這是@AXMIM 解決方案
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.