简体   繁体   English

XpsDocument GetFixedDocumentSequence返回null

[英]XpsDocument GetFixedDocumentSequence return null

I read data from printer like this: 我像这样从打印机读取数据:

  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

I tried also saving stream directly to the file and then read as File.ReadAllBytes(filePath), but result is the same. 我也尝试将流直接保存到文件中,然后读取为File.ReadAllBytes(filePath),但结果是相同的。

After I save stream to the file I can open it via XpsViewer without any problem. 将流保存到文件后,可以通过XpsViewer毫无问题地打开它。

Strange but it's working. 奇怪,但是正在工作。 I have to used XpsConverter.exe and convert .xps file to .xps. 我必须使用XpsConverter.exe并将.xps文件转换为.xps。 Here is @AXMIM solution 这是@AXMIM 解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM