Skip to content

XPS documents in .NET Core can't be opened #51929

Closed

Description

@wstaelens

Description

As adviced from /runtime/wpf I should open a ticket here for the dotnet/runtime team...


Please see dotnet/wpf#3546 for full details, test documents and many more.

.NET Framework 4.8 is able to open XPS files from printer driver containing many .piece files.


.NET 5 ( / .NET Core) is unable to open XPS files from printer driver containing many .piece files.

Activity

  1. ghost added
    untriaged
    on Apr 27, 2021
  2. KevinCathcart commented on May 9, 2021

    @KevinCathcart
    Contributor

    When porting System.IO.Packaging over to .NET Core, two features interrelated features were dropped: Streaming mode (which allows creation of interleaved parts), and support for reading/updating existing interleaved parts.

    The reason they were dropped was because the porter was under instruction to replatform the the code to use System.IO.Compression, instead of MS.Internal.IO.Zip. Since at the time, a major goal was still to keep the runtime size small by avoiding duplicated code, this made sense.

    However, part of the support for interleaved files (which is specific to Open Packaging Conventions) was implemented in the MS.Internal.IO.Zip namespace, and therefore was not ported, even though it could have been moved into to Packaging namespace where I would argue it should have been in the first place, and updated to be based on System.IO.Compression, just like the rest of the OPC specific code.

    This issue is basically requesting to restore the missing support for reading and updating interleaved files. The read and update support actually has no public API surface (unlike streaming), and its absence is a correctness issue, since support for reading interleaved OPC files is not optional in the specification. On the other hand, the ability to produce such files is optional, since interleaving is only meant as a possible performance enhancement, so restoring streaming mode is less important.

    It appears that all the needed code has been released under MIT, either as part of the initial commit of the code to this repository (where unfortunately, it had already been heavily modified from the original, so hopefully no needed code was removed, but it looks like most was just ifdefed out), or for the MS.Internal.IO.Zip code needed, was released as part of open sourcing WPF, although the code was deleted in later commits due to not being used by anything over there.

  3. wstaelens commented on May 10, 2021

    @wstaelens
    Author

    ok @KevinCathcart thanks for explaining in detail.

    What does it mean for us now? Will it be added again to .NET Core /.NET 5?

  4. KevinCathcart commented on May 10, 2021

    @KevinCathcart
    Contributor

    It is up to the area owners to decide if restoring such support is code they are willing to have and maintain. If it is then somebody needs to port the code, which while probably not hard, is also not completely trivial.

    Given that .NET 6 is already full in terms of planned projects, it would be unlikely to happen for that release unless a contributor creates a pull request. The chances of this being backported to older releases is pretty much zero, although as an OOB package, one ought to be able to reference a newer version from older net core based frameworks.

    Perhaps @carlossanlop or one of the other area owners can comment if a pull request fixing this regression vs .NET Framework (which is technically also a correctness issue) by porting the missing code might be accepted. As mentioned before there is no associated public API change. Instead, Zip-based OPC packages with interleaved parts would simply have those parts be visible again if opened with this package. Right now, such parts get silently ignored, which is not even easy for apps to detect is happening, unless they see a required part is missing or look in the zip file themselves.

  5. wstaelens commented on May 19, 2021

    @wstaelens
    Author
  6. added
    needs-further-triage
    and removed
    untriaged
    on Jun 23, 2021
  7. added this to the 7.0.0 milestone on Jun 23, 2021
  8. wstaelens commented on Oct 28, 2021

    @wstaelens
    Author
  9. wstaelens commented on Feb 9, 2022

    @wstaelens
    Author

    🥺 🤞 😭

  10. wstaelens commented on Jun 21, 2022

    @wstaelens
    Author

    @carlossanlop @jozkee what's the status of this?

  11. danmoseley commented on Jun 21, 2022

    @danmoseley
    Contributor

    Could this be achieved by using the code in a non Microsoft owned project?
    Is there a way to get a sense of the level of interest in this feature, such that it would justify the cost of maintenance etc?

  12. 15 remaining items

  13. wstaelens commented on Sep 19, 2023

    @wstaelens
    Author

    @ericstj what is the status? Can you make a push for .net 8 or do we have to wait another release?

  14. davidfowl commented on Sep 19, 2023

    @davidfowl
    Member

    .NET 8 is done.

  15. wstaelens commented on Sep 19, 2023

    @wstaelens
    Author

    😞 27-06-2016 - ... 2024? 2025? 7+ years have passed since .net core release without any fixes. fingers crossed...?

  16. wstaelens commented on Jan 30, 2024

    @wstaelens
    Author

    what is the status of this for .net 9 ?

  17. edwardneal commented on Jan 30, 2024

    @edwardneal
    Contributor

    I'm currently working on this, and hopefully there should be a PR ready for review "soon" - probably the next week or so, realistically. I'm adding test coverage for the new functionality as I go, but it doesn't do much to test the existing code. That particular gap should be triaged separately IMO.

    It's possible to control whether or not the XPS Document Writer printer triggers this behaviour, which makes it easier to test with real files. In the printer's advanced printing preferences, the interleaving option can be toggled off or on (the default behaviour is off.) Of course, this doesn't help particularly if you're not in control of the files you receive!

  18. wstaelens commented on Feb 5, 2024

    @wstaelens
    Author

    @edwardneal you can find test documents here:
    you can find some test files here from the xps jobs:
    dotnet/wpf#3546 (comment)

    In general, XPS still uses arraylists and code base could be improved. I often use this 900+ test document:
    https://spaenhiers.files.wordpress.com/2022/10/bidprentjes_2022-10-20.pdf

    imagine the performance boost if the STA thread requirement could be dropped.

  19. edwardneal commented on Feb 5, 2024

    @edwardneal
    Contributor

    Thanks. I briefly tested with file 02 outside of the automatic tests, and was able to enumerate, read and write its package parts.

    There are definitely performance and functionality improvements to be made from ZipArchive upwards. Some of the largest improvements need an API review, but I think they're ultimately necessary. I'd personally like to see async support in ZipArchive, some memory usage reductions, and to move thumbnails and digital signatures from XpsDocument to Package - they're part of the base OPC specification, and Office documents (and possibly NuGet packages and VSIX extensions) use them.

  20. wstaelens commented on Feb 8, 2024

    @wstaelens
    Author

    @edwardneal will these changes be backported to .net 6 and .net 7 (as some of our customers are stuck for months/years on .net 6/7....)

  21. edwardneal commented on Feb 11, 2024

    @edwardneal
    Contributor

    I don't know about .NET 6, but I'd be surprised if any new functionality was backported to .NET 7. MS' support lifecycle puts .NET 7 in Maintenance support, in which only security fixes are made.

    The process for requesting a backport is found here. It reads to me like you'll need to wait for the current PR to be merged, then raise a second PR requesting its backport.

  22. KevinCathcart commented on Feb 12, 2024

    @KevinCathcart
    Contributor

    I think it is unlikely for backports to be approved for this, but it also shouldn't be needed at least longer term, as if accepted it will become part of the System.IO.Packaging nuget that targets .NET Standard 2.0, so any impacted .NET 6 or .NET 7 or .NET 8 project should be able to just reference the 9.0 version of the package to add this functionality back.

    Unfortunately that NuGet probably won't contain builds targeting 6 or 7, so the .NET Standard 2.0 build would get used, I'd expect that would merely impact performance rather than functionality, and the resulting performance we are talking about here should still be at .NET Framework level or better, so quite unlikely to be a showstopper.

  23. wstaelens commented on Feb 12, 2024

    @wstaelens
    Author

    .net 6 would be great but not necessary. Backport to .net 7 would be needed.

    The problem is that some clients (gov, fortune500, ..) cannot install newer (internally not approved) .net releases on some servers, and at least not .net 8 / .net 9 (some even require that a release needs to be on the market for 6months or 1 year already to be approved as "ok" or "stable") That is why I asked if this will be backported so that we could roll this out to some customers. Minor releases from an approved framework version are faster accepted.
    🙄

    Appreciate already what you are doing! Let's make XPS great again 👍

  24. wstaelens commented on Feb 22, 2024

    @wstaelens
    Author

    @edwardneal would you be able to tackle this other EPIC issue with xps in .net? (dropping the STA requirement) dotnet/wpf#4000 (comment) 🤞 😃

    can't wait to test the changes in production 👍

  25. carlossanlop commented on Jul 19, 2024

    @carlossanlop
    Contributor

    We can consider this fixed by #97898 unless someone reports otherwise.

  26. locked and limited conversation to collaborators on Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.IO.Compressionhelp wanted

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions