Updated: April 19, 2017
Lo and behold, someone decided to send me an invoice as an XPS file. Not PDF. Ah well. XPS stands for Open XML Paper Specification, a new fixed-layout document format developed by Microsoft. In Windows 8 and onwards, the plot thickens further with oxps, and in all cases, things can be tricky to view or read if your operating system does not have the right software. PDF sounds like a better, wiser bet.
In this little guide, I will show you two ways of converting XPS files to the PDF format, so you can make sure they are viewable pretty much on any device you may have. We will do this using Linux tools. Follow me.
Most modern distributions have GPXS tools in the repos. For example, Fedora 25 offers the necessarity set of utilities under libgxps-tools, so just install those first. The commands are very similar for other distributions. Most people like to demonstrate using Ubuntu, but then I felt I should be special and unique, the way my mom always called me.
dnf install libgxps-tools
Once the software is installed, you will need to run xpstopdf, and it's a very simple program to run and use:
xpstopdf <source> <target>
The rendered PDF file may use different fonts from the original, because the free tools may not ship with some of the proprietary fonts used to create the XPS file. Overall, however, the output should be readable and fairly presentable.
Ghost tools are no stranger to us, and we have used them before when we tested LaTeX, Lyx and such. If you look at the Ghostscript download page, there are several different tools available, including PCL, PDF and XPS interpretter and renderer, plus the GhostPDL bundle, which comes with all these utilities combined, and this is what we will grab as we want to have everything. It is distributed as source code, and you will need to compile it yourself. Grab it from GitHub. First step. Extract the archive, for example:
tar xvzf ghostpdl-<version>.tar.gz
Now, run ./configure and finally make (all) to create all the binaries. You can also optionally install them if you're interested, or just manually move the generated objects into whatever directory you like. If you encounter any errors, this means you are missing some dev tools or headers, and you will need to replenish those first. On my Fedora 25 box, it all went well without any problems. You might want to consult my oldie but goldie howto on Linux commands and configurations. And we represent.
You will find gxps under the bin sub-directory of the extracted sources archive.
gxps -sDEVICE=pdfwrite -sOutputFile=file.pdf -dNOPAUSE file.xps
This looks crazy, but it's not that tricky. Finding the right documentation can be a little daunting, as the Ghostscript pages are many and convoluted, but you will soon have the clarity you need. The -sDEVICE option tells us the device we want to use, in this case the PDF writer - think PDF printer for that matter. The -sOutputFile is self-expanatory. The -dNOPAUSE option will disable interactive prompting and also gracefully quit if it encounters the EOF character or someone breaks the execution with Ctrl+C. If you're bored, these's so much more of this stuff available online. In a nutshell, notice that you specify the output first, the input last. And that's all. Again, there could be formatting and font differences compared to the original, but it should be very similar. Job done!
I love articles that involve GS, LaTeX and similar. These are so convoluted, they rival entire operating systems in their beauty and complexity. The same way glibc and gcc are an entire universe of wonder and pain. But now you have not one, but TWO methods of converting your files.
This started as an ugly exercise, and initially, I spent some time searching online, to no avail. But then, enter Linux! If you don't want to use third-party tools to just open and maybe convert XPS file, Linux gives you two fairly simple and clean methods of achieving the same results, plus the wealth of knowledge and pride in having accomplished this the leet way. East side, west side. Enjoy.
P.S. PDF icon on the home page, courtesy of Mimooh, licensed under CC BY-SA 3.0.