简体   繁体   中英

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.

After I save stream to the file I can open it via XpsViewer without any problem.

Strange but it's working. I have to used XpsConverter.exe and convert .xps file to .xps. Here is @AXMIM solution

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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