XPS (XML Paper Specification) and OpenXPS
| Full name | XML Paper Specification; OpenXPS (Open XML Paper Specification, ECMA-388) |
|---|---|
| Extensions | .xps, .oxps |
| MIME type | application/vnd.ms-xpsdocument (XPS), application/oxps (OpenXPS) |
| Type | fixed-layout document (vector graphics, text with embedded fonts, images) in a ZIP package |
| Starts with | 50 4B 03 04 (PK, a ZIP file); identified by the [Content_Types].xml part and a fixedrepresentation relationship |
| Specification | ECMA-388 Open XML Paper Specification |
| Maintained by | Ecma International (TC46); Microsoft for the original XPS 1.0 |
| License | open standard (Microsoft covers XPS under its Open Specification Promise) |
XPS is Microsoft’s answer to PDF: a page description format where every page is fixed, fonts are embedded and the file looks the same everywhere. It’s built on the same packaging as Office Open XML: a ZIP file with XML parts. Pages are written in a subset of XAML with three drawing elements: Path, Glyphs and Canvas.
XPS is part of the Windows print system. The Microsoft XPS Document Writer printer saves any document as .oxps (Windows 8 and later) or .xps (Windows 7), and the XPS print path sends XPS to printer drivers. OpenXPS (ECMA-388) is the standardized version of XPS 1.0 with new XML namespaces; the two are otherwise almost the same. Outside Windows printing, XPS is rare: use PDF for documents you share.
When to use XPS#
- Use when a Windows print workflow or driver uses XPS (XPSDrv, the XPS print path).
- Use when you receive
.xps/.oxpsfiles from “Print to XPS”; convert them to PDF to share. - Avoid for sharing documents: many systems have no XPS viewer, while PDF opens everywhere. Since Windows 10 1803 even the XPS Viewer is an optional Windows feature.
- Avoid when you need forms, digital signatures with broad support, or accessibility tooling: PDF has much wider support.
File structure#
An XPS document is an Open Packaging Conventions (OPC) package: a ZIP archive of parts, with relationships between them. A typical .xps file made by the XPS Document Writer:
[Content_Types].xml MIME type of every part, by extension or name
_rels/.rels start relationship -> FixedDocumentSequence.fdseq
FixedDocumentSequence.fdseq list of documents
Documents/1/FixedDocument.fdoc list of pages with their sizes
Documents/1/Pages/1.fpage page 1 markup
Documents/1/Pages/_rels/1.fpage.rels resources used by page 1
Documents/1/Resources/Fonts/0A1B2C3D-....odttf embedded (obfuscated) font
Documents/1/Resources/Images/1.png image
Documents/1/Structure/DocStructure.struct optional outline (bookmarks)
docProps/core.xml title, author, dates (core properties)
Metadata/Job_PT.xml PrintTicket: paper, duplex, copies
Part names and folder layout vary between producers; only the relationships are fixed. A reader finds the start part from _rels/.rels:
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="R0" Target="/FixedDocumentSequence.fdseq"
Type="http://schemas.microsoft.com/xps/2005/06/fixedrepresentation"/>
</Relationships>
OpenXPS uses the relationship type http://schemas.openxps.org/oxps/v1.0/fixedrepresentation instead.
Documents and pages#
The document sequence lists documents, each document lists pages:
<FixedDocumentSequence xmlns="http://schemas.microsoft.com/xps/2005/06">
<DocumentReference Source="Documents/1/FixedDocument.fdoc"/>
</FixedDocumentSequence>
<FixedDocument xmlns="http://schemas.microsoft.com/xps/2005/06">
<PageContent Source="Pages/1.fpage" Width="816" Height="1056"/>
</FixedDocument>
A page is a FixedPage element. Units are 1/96 inch: a Letter page is 816 x 1056, A4 is about 793.7 x 1122.5. The origin is the top-left corner.
<FixedPage xmlns="http://schemas.microsoft.com/xps/2005/06"
Width="816" Height="1056" xml:lang="en-US">
<Path Data="M 96,96 L 720,96 720,200 96,200 Z" Fill="#FF3366CC"/>
<Glyphs FontUri="/Documents/1/Resources/Fonts/0A1B2C3D-4E5F-6071-8293-A4B5C6D7E8F9.odttf"
FontRenderingEmSize="24" OriginX="96" OriginY="260"
Fill="#FF000000" UnicodeString="Hello, XPS"/>
<Canvas RenderTransform="0.5,0,0,0.5,96,300">
<Path Data="M 0,0 L 400,0 400,300 0,300 Z">
<Path.Fill>
<ImageBrush ImageSource="/Documents/1/Resources/Images/1.png"
Viewbox="0,0,400,300" ViewboxUnits="Absolute"
Viewport="0,0,400,300" ViewportUnits="Absolute"/>
</Path.Fill>
</Path>
</Canvas>
</FixedPage>
| Element | Purpose |
|---|---|
Path |
vector shape: geometry in Data (SVG-like path syntax) or PathGeometry, with Fill, Stroke, Opacity, Clip |
Glyphs |
a run of text in one font: UnicodeString for the text, Indices for exact glyph IDs and advances |
Canvas |
group with a shared transform, clip, opacity or mask |
| brushes | SolidColorBrush, LinearGradientBrush, RadialGradientBrush, ImageBrush, VisualBrush |
Colors are #AARRGGBB (alpha first) or scRGB/ICC colors. XPS supports transparency everywhere, unlike PostScript.
Fonts and images#
- Fonts are TrueType/OpenType files, usually subsetted. Obfuscated fonts (
.odttf) have their first 32 bytes XORed with the GUID in the file name, to stop casual copying; any reader can undo it. - Images are JPEG, PNG, TIFF or JPEG XR (HD Photo,
.wdp/.jxr). - Text is searchable because
GlyphscarryUnicodeString. Producers may omit it, in which case text can’t be extracted.
XPS vs OpenXPS#
| XPS 1.0 (Microsoft) | OpenXPS (ECMA-388) | |
|---|---|---|
| Extension | .xps |
.oxps |
| Main namespace | http://schemas.microsoft.com/xps/2005/06 |
http://schemas.openxps.org/oxps/v1.0 |
| Written by | Windows Vista/7, .NET System.Windows.Xps |
Windows 8 and later XPS Document Writer |
The page model is the same. The Windows 7 XPS Viewer can’t open .oxps; current viewers (SumatraPDF, MuPDF, libgxps) open both.
Converting XPS#
# XPS/OXPS to PDF
mutool convert -o out.pdf in.oxps # MuPDF
gxps -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=out.pdf in.xps # GhostXPS
xpstopdf in.xps out.pdf # libgxps tools
# XPS pages to PNG at 150 dpi
mutool draw -r 150 -o page-%d.png in.xps
On Windows, printing a PDF or any document to “Microsoft XPS Document Writer” creates an .oxps file; “Microsoft Print to PDF” turns an XPS opened in XPS Viewer into PDF.
Specifications and documentation#
- ECMA-388 Open XML Paper Specification (Ecma International): the OpenXPS standard (1st edition PDF)
- XPS printing documentation (Microsoft Learn)
- Microsoft XPS Document Writer (Microsoft Learn)
- Documents in WPF:
FixedDocumentand XPS in .NET - Open XML Paper Specification on Wikipedia
Software that opens XPS files#
| Software | Windows | macOS | Linux | Web | Can | Notes |
|---|---|---|---|---|---|---|
| SumatraPDF | ✓ | view | free, open source; opens .xps and .oxps | |||
| XPS Viewer | ✓ | view | Microsoft; an optional Windows feature since Windows 10 1803 (Settings > Optional features) | |||
| Microsoft XPS Document Writer | ✓ | create | built-in virtual printer; saves any printout as .oxps | |||
| MuPDF | ✓ | ✓ | ✓ | view, convert | AGPL or commercial; mutool convert to PDF. Also on Android | |
| Okular | ✓ | view | free, open source KDE viewer | |||
| Evince | ✓ | view | GNOME document viewer, through libgxps | |||
| Zathura | ✓ | view | with the MuPDF plugin | |||
| GhostXPS | ✓ | ✓ | convert | XPS interpreter from the Ghostscript family (gxps); AGPL or commercial |
Libraries#
Open-source libraries that read, render and write XPS. See all XPS libraries for a comparison.
| C/C++ | libgxps, MuPDF |
|---|---|
| C# | System.Windows.Xps |
| Python | PyMuPDF |
| Rust | mupdf |
Related formats#
- PDF: the much more widely supported fixed-layout format
- OFD: Chinese fixed-layout document standard, also a ZIP of XML pages, modeled on XPS
- ZIP: the container XPS uses
- JPEG XR: image format that originated with XPS (HD Photo)
- PostScript: the older printer language XPS replaces in the Windows print path