How to create an XPS document?
If you are working in .NET (v2 or later), you can very easily generate a valid XPS document from a WPF visual.
For an example, take a look at this blog post of mine:
http://nixps.blogspot.com/2008/12/wpf-to-pdf.html
In the example I create a WPF visual and convert it as an XPS file, before doing further processing.
If you are not working in .NET, or want more control on the XPS output, then I would advise you to use a library (like the NiXPS SDK) for this. It is a lot easier to code for, and a lot less error prone than writing out the XML constructs yourself (and doing proper resource management, etc...).
Comments
-
Sam over 4 years
I'd like to create an XPS document for storing and printing.
What is the easiest way to create an XPS document (for example with a simple grid with some data inside) in my program, and to pass it around?
-
Admin over 15 yearsBizarre. But definitely one way you can do it. I wouldn't suggest doing it this way unless you understood the XPS document specifications.
-
Sam over 15 yearsCreating a bizarre XML document, compressed into a zip? Not exactly what I had in mind when I wrote 'easiest way' :)
-
Sam over 15 yearsThe link to your blog does not work, maybe you can copy the code example in your answer instead?
-
Kristof Van Landschoot over 15 yearsCopy and paste the URL instead of following it, it's just the href that is wrong. It shows perfectly how to create an XPS-file from a WPF visual.
-
mistertodd over 12 yearsWPF (Windows Presentation Foundation) wasn't released until .NET Framework 3.0 (with Windows Vista)
-
itsho about 9 yearsNotice: NiXPS SDK costs money (750€ is the cheapest package at the moment)
-
Patrick D'Souza about 9 yearsNiXPS seems dead at the moment. The homepage nixps.com shows a blank page and the last time the news was updated was 2010 (nixps.com/news.php?id=1)
-
Germán Martínez over 3 yearsIs this tutorial still available anywhere? The blog's gone - but I'm quite interested...