SUBMIT A FILE TYPE CONTACT US SUPPORT ABOUT US

What Is an XPS File? The Microsoft Fixed-Layout Document, and How to Open, Convert and Check One

An XPS file is a fixed-layout document made by Microsoft. Three readers gave one answer on 6 of the 21 damaged copies we made of one. Jump to your question below, or work through it in order.

30 min read Updated November 2026 Checked against sources and tests

What Is an XPS File? The Microsoft fixed-layout document, and why it still shows up

Short answer

An XPS file is a fixed-layout document made by Microsoft. It keeps the text, fonts, images and page shapes of a document in a ZIP package of XML parts. A page looks the same on every screen and printer.

We tested 21 XPS files with three readers, MuPDF, xpstopdf and 7-Zip. 18 opened in all three. We then damaged one file in 21 ways, and the three readers gave one answer on only 6 copies.

To see inside one, use the open steps. To make a PDF from one, use the convert steps. If your XPS file will not open, begin with the causes.

An XPS file is a fixed-layout document made by Microsoft. It stores the text, fonts, images and shapes of every page in a ZIP package of XML parts. A page keeps the same look on every screen and printer.

Picture a file named invoice.xps that your printer software made. You send it to a friend, and the friend sees the same page breaks and the same fonts that you saw. That is the job of the format. Now picture a second file, named scan.xps, that no program will open.

Wikipedia says Microsoft developed the format as the XML Paper Specification, with an initial release in October 2006. Ecma International adopted it as ECMA-388, and its General Assembly approved the standard on June 16, 2009. The standard goes by the name Open XML Paper Specification, or OpenXPS.

Wikipedia names two endings. The .xps ending came first and was used by Windows Vista and Windows 7. The .oxps ending belongs to the Ecma standard, and Windows 8 made it the default of its document writer. Wikipedia adds that older Windows versions do not support .oxps on their own.

A program makes an XPS file when you print to the XPS Document Writer, a virtual printer that Windows includes, per Wikipedia. Windows Vista also used XPS as its spooler format. Microsoft offered the format as an alternative to PDF, but PDF stayed the usual choice.

The viewer changed over time. Windows Central reported that new installs of Windows 10 version 1803 no longer include XPS Viewer, and that an upgrade from version 1709 keeps it. You add it from Settings, under Apps and Optional features. The same article says Microsoft no longer maintains the app.

Where our XPS files come from

We studied 21 files. 10 are public test files from three GitHub projects. GhostPDL gave 3, dotnet/wpf gave 1 and Apache Tika gave 6. We made the other 11 ourselves with a Python script, so that every one changes a single thing.

The files are 1,536 to 560,946 bytes long, and the median is 36,170 bytes. They are test XPS files and not documents from offices. We opened none in Windows XPS Viewer, because our lab uses Linux. We make no claim about what that viewer shows.

So this page studies how readers treat the layout. We used MuPDF 1.28.6 through PyMuPDF, xpstopdf from libgxps 0.3.2 and 7-Zip 23.01 as the three readers. We used Python and its zipfile module for the container.

XPS file facts at a glance

Quick facts about XPS files
Property Value
Meaning XML Paper Specification, also called Open XML Paper Specification or OpenXPS, per Wikipedia.
Endings .xps and .oxps, per Wikipedia.
Maker Microsoft. Ecma International adopted it as ECMA-388 in June 2009.
Readers Windows XPS Viewer, which new installs of Windows 10 version 1803 lack. FileInfo lists more programs.
Layout A ZIP package with a start relationship, a document sequence, documents, pages and resources, per our tests.
First bytes 50 4b 03 04, the letters PK, in 20 of our 21 files.
Media types application/vnd.ms-xpsdocument and application/oxps, per Wikipedia.
Page size Our pages are 816 by 1056 units. Both converters gave 612 by 792 points, so a unit is 1/96 inch.
Our tests 21 files, 21 damaged copies, 3 readers, a check script of 30 lines and a repair script of 11 lines.

Looking for a document that prints the same everywhere? The PDF file overview covers the format that XPS tried to replace.

Which Kind of XPS File Do You Have? Three kinds, and the first bytes name the kind

Three kinds of file use the .xps ending in our tests. They are a Microsoft XPS ZIP file, an OpenXPS ZIP file and an OLE file. The first bytes and the namespace name the kind, and the ending does not.

The ending of an XPS file is a label that anyone can change. In our 21 XPS files, 20 start with the letters PK and 1 starts with the OLE bytes. Of the 20, 18 use the Microsoft namespace and 2 use the OpenXPS namespace. Follow the figure.

Decision chart with three kinds of file named .xps: a Microsoft XPS ZIP file, an OpenXPS ZIP file and an OLE file, with the number of files that MuPDF, xpstopdf and 7-Zip opened.
Figure 1. Three kinds of file named .xps, found by the first bytes and the namespace.

The kinds in detail

Three kinds of file named .xps and how three readers handled them
Kind Files and results
Microsoft XPS 18 of 21 files. MuPDF and 7-Zip opened all 18. xpstopdf opened 16 and refused 2 public files over a ZIP size error.
OpenXPS 2 of 21 files. One is ours, with the ending .oxps. The other is a public file from Apache Tika. All three readers opened both.
An OLE file 1 of 21 files. Invalid_1.xps from dotnet/wpf starts with the OLE bytes. Its only stream is named EncryptedPackage and contains 0 bytes. All three readers refused it.

Read the first bytes

The file command named our example Microsoft OOXML, which points to a package and not to XPS. So the command is a first clue and not an answer. Look at the parts in the package, as the check part shows.

First bytes and names in 21 files
Value What we measured
First four bytes 50 4b 03 04 in 20 files. d0 cf 11 e0 in 1 file.
Start part name 16 of the 20 ZIP files name it FixedDocumentSequence.fdseq and 4 name it FixedDocSeq.fdseq. A reader finds it through the relationship, so the name does not matter.
Namespace 18 files use http://schemas.microsoft.com/xps/2005/06 and 2 use http://schemas.openxps.org/oxps/v1.0.
File size 2 files are under 10,000 bytes, 15 are 10,000 to 99,999 bytes and 4 are 100,000 bytes or more.
First bytes first The letters PK name a ZIP file. The bytes d0 cf 11 e0 name an OLE file, and no ZIP reader opens it.
The start part second Look in _rels/.rels for a relationship that ends in fixedrepresentation. It names the first part.
The namespace third The namespace in a page names the Microsoft kind or the OpenXPS kind.
The ending last The ending is a label. One .xps file in our test set is an OLE file.

Is your file a ZIP archive and not a document? The ZIP file overview covers that container.

What Is Inside an XPS File? A ZIP package of XML pages, fonts and images

An XPS file is a ZIP package. Our example is 25,976 bytes long and has 11 parts. A start relationship leads to a document sequence, a document, 2 pages, a font and an image.

We looked inside one XPS file because its layout explains every result later on this page. Our own01_base.xps is a file we made with Python. It has 2 pages and 114 characters of text. Its first bytes show the ZIP header and the first part name.

The start of one XPS file
xxd -l 48 own01_base.xps
00000000: 504b 0304 1400 0000 0800 2262 665d d81e  PK........"bf]..
00000010: ef50 1601 0000 ed02 0000 1300 0000 5b43  .P............[C
00000020: 6f6e 7465 6e74 5f54 7970 6573 5d2e 786d  ontent_Types].xm

The file starts with 50 4b 03 04, the local header of the first part. The part name [Content_Types].xml follows at byte 30. 7-Zip lists 11 parts of 34,696 bytes in all, and the ZIP file is 25,976 bytes long.

Diagram of one XPS file of 25,976 bytes in six parts: the ZIP container, the content types file, the relationships file, the sequence, document and pages, the font and image resources, and the markup inside one page, with three rules about the container, the links and the page XML.
Figure 2. One XPS file made by us, own01_base.xps. The parts are not drawn to scale.

The parts, one by one

A reader starts at _rels/.rels. It finds the relationship that ends in fixedrepresentation, and the target is /FixedDocumentSequence.fdseq. That part lists one document. The document part lists two pages, and every page lists the resources it needs in a small rels file.

Every page is a FixedPage tag with a width and a height. Ours read 816 by 1056. Both xpstopdf and PyMuPDF made pages of 612 by 792 points, which is 8.5 by 11 inches. So 816 units equal 8.5 inches, and a unit is 1/96 inch.

What every part stores

Parts of XPS files and what we saw
Part What it stores
ZIP header The letters PK and the part names. Copy A1 changes the first two bytes. MuPDF and xpstopdf refused it, and 7-Zip opened it. Our repair script restores it.
ZIP directory A list of parts at the end of the file. Copies A3 and A6 damage it. MuPDF and 7-Zip refused both, and xpstopdf read both as the original.
Content types The type of every part, by ending. Copy B1 removes it. All three readers read the copy as the original, and our script printed a warning.
Start relationship The file _rels/.rels. Copy B2 removes it. xpstopdf refused the copy, and MuPDF gave another answer.
Sequence and document Copies B3 and B4 remove one of them. xpstopdf refused both, and MuPDF gave another answer on both.
Pages XML with Glyphs tags for text and Path tags for shapes. Copy C1 cuts a page in half, and MuPDF and xpstopdf refused it.
Font and image A font ending in odttf and a PNG. Copy B6 removes the font, and xpstopdf reported a render error. Copy B7 removes the image, and all three readers read it as the original.

What the public pages say about the layout

The Library of Congress page says an XPS file is an Open Packaging Conventions package with a ZIP container. Its root is a FixedDocumentSequence part. Every FixedDocument part lists its FixedPage parts, and every page has a fixed width and height.

The same page says text uses Glyphs tags and vector graphics use Path and Brush tags. Fonts and images are separate parts. It calls a readable part name, for example /Documents/1/Pages/1.fpage, a recommendation and not a requirement.

The map is small. Our script checks the ZIP, the start relationship, the document chain, the page size and the resources. It does not draw a page. Copy A7 shows the limit, because the script printed OK for it and MuPDF and 7-Zip still treated it another way than the original.

What Did We Find in 21 Test XPS Files? Three readers, and 18 files opened in all of them

We tested 21 XPS files with three readers. 18 opened in all three, 1 opened in none and 2 split the readers. xpstopdf refused 2 public files that MuPDF and 7-Zip opened. All 11 files we made opened everywhere.

We counted an XPS file as opened when a reader gave output without an error. MuPDF counted the pages and the characters of text. xpstopdf wrote a PDF file. 7-Zip listed the parts and had to see a ZIP file. We used MuPDF 1.28.6, libgxps 0.3.2 and 7-Zip 23.01 on Linux.

Bar chart of 21 test XPS files by size, from 1,536 bytes to 560,946, next to the number of files that three readers opened, a grid of results by kind of file, and four measured facts.
Figure 3. 21 files, three readers and four measured facts.
21 test files
18 opened in all three readers
2 opened in only some readers
1 opened in none

What the numbers show

Findings from 21 test files
Finding What we measured
Most files open 18 of 21 files opened in all three readers. MuPDF opened 20, xpstopdf 18 and 7-Zip 20.
xpstopdf refused two files testXLSX.xps and test_text.xps from Apache Tika. Its error begins with ZIP uncompressed data is wrong size. 5 other files with the same data descriptor flag opened, so we did not find the cause.
One file is not a ZIP file Invalid_1.xps from dotnet/wpf starts with the OLE bytes and has one empty stream named EncryptedPackage. All three readers refused it.
Two documents split the count Our own09_two_documents.xps has 3 pages in 2 documents. MuPDF counted 3 pages and xpstopdf wrote 2.
Drawings have no text MuPDF found 0 characters of text in 3 files. Two are tiger drawings from GhostPDL and one is our file made of shapes only. All three readers opened all three.
The parts vary Of 20 ZIP files, 17 have a font part, 18 have an image, 9 have a thumbnail and 7 use data descriptors. 2 store every part without compression.

What this study cannot show you

These are test files from three open projects, and we made 11 of them. Many exist to test one feature. A refusal on the OLE file is the right answer, because it is not an XPS package.

We opened no XPS file in Windows XPS Viewer. Output from a reader does not mean that Microsoft software would open the file, and it does not mean that the page looks right. We compared page counts and text length, and we did not compare pictures of the pages.

What Happens When an XPS File Is Damaged? 21 broken copies, and the three readers agreed on 6

We damaged one XPS file in 21 ways. The three readers gave one answer on 6 copies and split on 15. Our script printed OK on 4 copies, and one of those, A7, changed what two readers returned.

Our base XPS file is own01_base.xps, 25,976 bytes. We changed one thing at a time and saved 21 copies. Same means a reader gave the page count and text length it gave on the original. Refused means it stopped with an error. Differs means it gave another answer.

Grid of 21 damaged copies of one XPS file against MuPDF, xpstopdf, 7-Zip, our check script and a repair script. The three readers gave one answer on 6 copies, our script printed OK on 4, and the repair script restored 4 copies.
Figure 4. 21 damaged copies, three readers, our script and a repair script.

The three readers check different things. 7-Zip handles the ZIP index and the part list only. MuPDF and xpstopdf read the pages, and they follow the links between parts in different ways.

What the grid shows

Results for 21 damaged copies of one XPS file
Copies What happened
A wrong first two bytes Copy A1 changes PK to XX. MuPDF and xpstopdf refused it, and 7-Zip opened it. The repair script restores it, and all three readers then gave the original answer.
A wrong ZIP directory Copy A3 removes the end record, A6 gives a wrong directory offset and A7 sets the entry count to 3. MuPDF refused A3 and A6 and found 0 pages in A7. 7-Zip refused all three. xpstopdf read all three as the original.
A cut file Copy A2 cuts the file in half. MuPDF and 7-Zip refused it, and xpstopdf reported an error on a page.
A text mode transfer Copy A4 changes every LF into CRLF. All three readers refused it.
A flipped byte in a page Copy A5 flips one byte in the compressed data of page 1. MuPDF and xpstopdf refused it. 7-Zip listed it, and 7z t then reported a data error for the page.
A missing part Copies B2, B3 and B4 remove the start relationship, the sequence and the document. xpstopdf refused all three, and MuPDF gave another answer. Copy B5 removes page 2, and MuPDF refused it. B1, B6 and B7 remove the content types, the font and the image.
A broken page Copy C1 cuts page 1 in half and C2 adds a control byte. MuPDF and xpstopdf refused both, and 7-Zip read both as the original. Copy C4 sets the page size to 0, and MuPDF gave another answer.
A changed label Copy C3 changes the namespace, C5 undoes the font scramble and C6 sets the page type to text. All three readers gave the original answer on all three. Copy C7 renames the font, and xpstopdf reported a render error.

The pattern is clear. When the ZIP index breaks, MuPDF and 7-Zip stop and xpstopdf keeps going. When a link between parts breaks, xpstopdf stops first. A changed label changed nothing in our three tests, because the readers do not check it.

Our script and the repair script

Our check script printed OK for 4 copies and WARN or FLAG for 17. Of the 4 OK copies, 3 read as the original in all three readers. Copy A7 did not. Copies B1 and B7 got a warning and still read as the original everywhere. See the script.

The repair script rebuilds the ZIP from the local headers. It made all three readers give the original answer on 4 copies, A1, A3, A6 and A7. For A3, A6 and A7 the rebuilt file has the same 11 parts with the same bytes. For A1 it rebuilt 10 parts and dropped the one with the damaged header.

The script cannot restore a cut file, a changed part or a text mode copy. We did not test a repaired file in Windows XPS Viewer.

Why a text mode copy is special

Copy A4 changes LF into CRLF, and a text mode transfer does the same. Our base file has 101 LF bytes and 3 CRLF pairs. Replacing every CRLF pair in A4 with LF gave back the original file, byte for byte.

Do not apply that replacement to a good XPS file. 15 of our 20 ZIP files contain a CRLF pair by chance, and the replacement damaged our base file by 3 bytes. So reverse a text mode copy only after you know the transfer made it. A new download in binary mode is the better fix.

What Does Our Expert Say About XPS Files? A note from Neeraj Singh on trusting one tool

We asked our expert what the grid means for someone who has an XPS file and has to decide if it is damaged. He read the 21 copies and the three reader columns.

Neeraj Singh

Expert insight

Never trust one reader. In our tests 7-Zip listed a copy with a flipped byte as fine, and MuPDF opened a copy with a wrong entry count and found no pages. Open the file in a second reader that draws the pages, and compare the page count before you decide it is sound.

Neeraj Singh Manager, Tech Support & Operations 19+ years fixing Windows and system errors

That advice fits the grid. MuPDF and xpstopdf gave the same answer on 10 of the 21 copies. MuPDF and 7-Zip agreed on 11, and xpstopdf and 7-Zip on 6. A second reader that checks the file in a different way is the cheapest test.

How Do You Open an XPS File? A viewer, MuPDF and 7-Zip, with the commands we tested

To open an XPS file on Windows, double-click it in XPS Viewer, which new installs of Windows 10 version 1803 lack. Without it, MuPDF opened 20 of our 21 files, xpstopdf 18 and 7-Zip 20. A reader that opens an XPS file does not prove the XPS file is sound.

Windows Central reported that you add XPS Viewer from Settings, under Apps, Apps and features, Manage optional features and Add a feature. Our lab uses Linux and has no Windows machine, so we did not test the viewer. The tools below are the ones we used.

Your options

XPS Viewer Not tested The Microsoft viewer. New installs of Windows 10 version 1803 do not include it, and an upgrade from version 1709 keeps it.
MuPDF Tested Opened 20 of our 21 files. It counts pages, draws them and extracts text. We used it through PyMuPDF.
xpstopdf Tested A tool from libgxps. It opened 18 of 21 and writes a PDF file. It refused 2 public files that MuPDF opened.
7-Zip Tested Opened 20 of 21 as ZIP files and lists the parts. It cannot draw a page.
LibreOffice Tested Version 24.2.7.2 said source file could not be loaded for our example file.
Other programs Not tested FileInfo lists more programs that open XPS files. We did not use them.

Look at the pages without Windows

Start with the page count and the first line of text. It changes nothing in the XPS file. Our example has 2 pages. MuPDF reports page 1 as 612 by 792 points, and the text of the page starts with its title.

The pages of one XPS file, counted with PyMuPDF
python3 -c "import pymupdf; d = pymupdf.open('own01_base.xps'); print(d.page_count, 'pages, page 1 is', d[0].rect); print(d[0].get_text().splitlines()[0])"
2 pages, page 1 is Rect(0.0, 0.0, 612.0, 792.0)
XPS page 1 title

See the parts

An XPS file is a ZIP package, so 7-Zip and unzip list its parts. Our example has 11 parts of 34,696 bytes. You can pull out one part, for instance the image, and check its type. Ours is a PNG of 64 by 48 pixels.

The parts of one XPS file
unzip -t own01_base.xps | tail -1
No errors detected in compressed data of own01_base.xps.
unzip -p own01_base.xps Resources/Images/pic.png > pic.png
file -b pic.png
PNG image data, 64 x 48, 8-bit/color RGB, non-interlaced

PyMuPDF can also draw a page to an image. At 96 dots per inch, page 1 of our example came out as 816 by 1056 pixels. That equals the page size in the file, so one unit is one pixel at 96 dots per inch.

Count the pages first MuPDF shows the page count before you convert anything.
Use a second reader xpstopdf refused 2 files that MuPDF and 7-Zip opened.
Mind the page count MuPDF counted 3 pages and xpstopdf wrote 2 for a file with two documents.
Know the limit LibreOffice 24.2.7.2 could not load our example file, so do not count on a word processor.

Is the file a Word document? The page on Word DOC files covers that format.

How Do You Convert an XPS File to PDF? Two tools, tested on one file

To convert an XPS file to PDF without Windows, use xpstopdf or PyMuPDF. Both made a 2 page PDF file from our example with the same text and the same page size of 612 by 792 points. The two PDF files are 16,130 and 27,579 bytes.

Both tools gave an identical page count and text. They differ in size, because the two tools write the PDF file in their own ways. We checked the results with pdfinfo and pdftotext from Poppler 24.02.0.

Convert it with xpstopdf

The tool takes two names, the XPS file and the PDF file. It wrote 16,130 bytes for our example. It embedded the font and kept the image.

xpstopdf makes a PDF file from one XPS file
xpstopdf own01_base.xps out.pdf
pdfinfo out.pdf | grep -E "^(Pages|Page size)"
Pages:           2
Page size:       612 x 792 pts (letter)
pdftotext out.pdf - | head -2
XPS page 1 title
This is a test page made for the study.

Convert it with PyMuPDF

The short script below opens the XPS file and saves a PDF file. It printed that 2 pages were written, and the file was 27,579 bytes. Poppler found the same two titles in it. We used PyMuPDF with MuPDF 1.28.6.

PyMuPDF makes a PDF file from one XPS file
import pymupdf, sys
doc = pymupdf.open(sys.argv[1])
pdf = pymupdf.open('pdf', doc.convert_to_pdf())
pdf.save(sys.argv[2])
print(doc.page_count, 'pages written to', sys.argv[2])
python3 py_convert.py own01_base.xps py.pdf
2 pages written to py.pdf
What we checked after the conversion
Check Result
Pages Two pages in both PDF files, the same as in the XPS file.
Page size 612 by 792 points, which is 8.5 by 11 inches, in both PDF files.
Text pdftotext found the titles XPS page 1 title and XPS page 2 title in both files.
Image The image part came through in both files, and Poppler lists 1 image on page 2.
File size 16,130 and 27,579 bytes against 25,976 bytes in the XPS file.

Convert it on Windows

We did not test any route on Windows, so this page makes no claim about one. If you have the viewer, compare its page count with the page count of the PDF file that you made.

What we did not test. We used no Windows machine and no Windows XPS Viewer. We converted one small XPS file with two tools. We make no claim about fonts of other kinds, gradients, transparency or digital signatures in other files.

Does the conversion fail? Read the list of causes before you try another tool. To learn about the target format, see the page on PDF files.

How Do You Check an XPS File? Six steps and a script of 30 lines

Check an XPS file in six steps. Copy it first. Then look at the first bytes, test the ZIP, follow the start relationship, check the parts and use a second reader. Our script of 30 lines does steps two to five.

  1. Copy the XPS file and work on the copy. Keep the original.
  2. Look at the first bytes with xxd -l 48 file.xps. They must read 50 4b 03 04, the letters PK.
  3. Test the ZIP with unzip -t file.xps or 7z t file.xps. A flipped byte in a part shows up as a data error.
  4. Open _rels/.rels and find the relationship that ends in fixedrepresentation. Its target must exist in the package.
  5. Follow the chain to the document and the pages. Every page needs a width and a height, and every font and image it names must exist.
  6. Open the file in two readers. Compare the page counts.

The check in Python

Our script of 30 lines does steps two to five with the standard library. It prints OK with the page and part counts. It prints WARN with the problems it found or FLAG and stops. It draws no page, so it cannot see everything.

xps_peek.py, 30 lines
import sys, zipfile, re, posixpath
from xml.dom import minidom
f = sys.argv[1]; d = open(f, 'rb').read(); w = []
if d[:4] != b'PK\x03\x04': sys.exit('FLAG not a ZIP file, first bytes ' + d[:4].hex())
try: z = zipfile.ZipFile(f); bad = z.testzip()
except Exception as e: sys.exit('FLAG ZIP will not open: %s' % e)
if bad: sys.exit('FLAG part %s fails its CRC check' % bad)
n = {x.lower(): x for x in z.namelist()}
def has(p): return p.lstrip('/').lower() in n
def xml(p):
    try: return minidom.parseString(z.read(n[p.lstrip('/').lower()]))
    except Exception as e: sys.exit('FLAG %s is not valid XML: %s' % (p, str(e)[:50]))
if not has('[Content_Types].xml'): w.append('no [Content_Types].xml')
if not has('_rels/.rels'): sys.exit('FLAG no _rels/.rels, so no start part')
rels = xml('_rels/.rels').getElementsByTagName('Relationship')
st = [r.getAttribute('Target') for r in rels if r.getAttribute('Type').endswith('fixedrepresentation')]
if not st or not has(st[0]): sys.exit('FLAG no fixed document sequence for the start part')
pages = 0
for dr in xml(st[0]).getElementsByTagName('DocumentReference'):
    doc = dr.getAttribute('Source')
    if not has(doc): sys.exit('FLAG missing document part ' + doc)
    for pc in xml(doc).getElementsByTagName('PageContent'):
        pg = posixpath.normpath(posixpath.join(posixpath.dirname(doc), pc.getAttribute('Source')))
        if not has(pg): sys.exit('FLAG missing page part ' + pg)
        fp = xml(pg).documentElement; pages += 1
        if float(fp.getAttribute('Width') or 0) <= 0 or float(fp.getAttribute('Height') or 0) <= 0: w.append('page %d has no size' % pages)
        for t in set(re.findall(r'(?:FontUri|ImageSource)="([^"]+)"', (lambda x: x.decode('utf-16' if x[:2] in (b'\xff\xfe', b'<\x00') else 'utf8', 'ignore'))(z.read(n[pg.lstrip('/').lower()])))):
            r = t.split(';')[-1]; r = r if r.startswith('/') else posixpath.normpath(posixpath.join(posixpath.dirname(pg), r))
            if not has(r): w.append('missing resource ' + t)
print(('WARN ' + '; '.join(w)) if w else 'OK %d pages, %d parts' % (pages, len(n)))

What the script prints

The first example is a good file, and it counts 2 pages and 11 parts. The second is copy A1, which starts with XX. The third is copy B7, which has no image part. The fourth is the OLE file from dotnet/wpf.

Four examples of the check script
python3 xps_peek.py own01_base.xps
OK 2 pages, 11 parts
python3 xps_peek.py A1.xps
FLAG not a ZIP file, first bytes 58580304
python3 xps_peek.py B7.xps
WARN missing resource /Resources/Images/pic.png
python3 xps_peek.py Invalid_1.xps
FLAG not a ZIP file, first bytes d0cf11e0

The repair script

The repair script of 11 lines scans for local ZIP headers and writes every part it can inflate into a new ZIP file. It restored 4 of our 21 damaged copies. It printed that it rebuilt 10 parts for A1, and the new file then drew both pages.

xps_fix.py rebuilds a ZIP file from its local headers
python3 xps_fix.py A1.xps A1_fixed.xps
rewrote 10 parts

Read the limits. Copy A7 got OK from the script, yet MuPDF found 0 pages in it and 7-Zip refused it. Copies B1 and B7 got a warning and read as the original everywhere. So an OK from one script is a start, and a second reader is the test.

Is the file a ZIP archive and not a document? The page on ZIP archives covers how to test one.

Is an XPS File Safe to Open? Listing the parts is safe, and opening needs care

Looking at the parts of an XPS file starts nothing. Our 20 ZIP files contained pages, fonts, images and labels, and no script parts. A file from an unknown source still needs care, so check what it is before you open it.

Wikipedia lists an XPS file can include page markup, text, embedded fonts, raster images, vector graphics and digital rights management information. A viewer parses all of those parts. A reader with a flaw in its font or image code is a risk that this page did not test.

Our lab only looked at XPS files. We used unzip, 7z, MuPDF, xpstopdf and our own scripts on 21 files, and we opened none in Windows XPS Viewer. We scanned no file for malware, so we make no claim about the files in our set or about yours.

Listing the parts is safe 7z l and our check script list parts and start nothing. We used them on 21 files.
We found no script parts The 20 ZIP files contain parts that end in fpage, fdoc, fdseq, rels, xml, odttf, png, jpg, jpeg, frag and struct. None of those is a program.
The packages are small The largest file expands to 1,698,967 bytes, and no file expands to more than 3.13 times its size. The most parts in one file is 207.
The ending is a label One of our .xps files is an OLE file. Look at the first bytes before you trust the ending.
An empty stream proves little That OLE file has a stream named EncryptedPackage with 0 bytes. We did not decrypt anything, and we make no claim about what a working encrypted file contains.
Work on a copy Keep the original unchanged. Our scripts write a new file and leave the source alone.

Five steps for a file you do not know

  1. Get the file from a source you trust, and keep the original.
  2. Look at the first bytes. A file that starts with 50 4b 03 04 is a ZIP file, and d0 cf 11 e0 is something else.
  3. List the parts with 7z l. Be careful with any part that ends in .exe, .dll or .js.
  4. Open a copy in an updated reader, and keep the reader up to date.
  5. Convert a copy to PDF and look at that file if you only want to read the pages.

What we did not test. We did not scan for malware, we did not test a font flaw and we did not open a file in Windows XPS Viewer. These checks lower the chance of a surprise, and they do not remove it.

Why Will Your XPS File Not Open? Eight causes, and what to do about every one

Eight causes stop an XPS file from opening, and the XPS file is the cause in only some of them. Start with the first bytes. A file that does not start with the letters PK is not a ZIP package, and no XPS reader opens it.

Work down the list in order. Cause one comes from the Windows Central report on version 1803. Cause seven comes from Wikipedia. Causes two to six and eight come from our 21 damaged copies and 21 files, so every fix names a copy or a count.

1. The computer has no viewer New installs of Windows 10 version 1803 do not include XPS Viewer. Add it from the Optional features list in Settings, or use MuPDF or xpstopdf as we did.
2. The file is not a ZIP file Invalid_1.xps starts with d0 cf 11 e0, and all three readers refused it. Ask the sender for the file again, and ask what program made it.
3. A text mode transfer changed it Copy A4 changes every LF into CRLF, and all three readers refused it. Download the file again in binary mode. Reverse the change only if you know the transfer made it.
4. The file is cut short or the ZIP index is wrong Copy A2 cuts the file in half and every reader failed or changed its answer. Copies A3, A6 and A7 damage the index. xpstopdf read all three as the original, and our repair script restored all three.
5. A part is missing Copies B2, B3 and B4 remove the start relationship, the sequence and the document, and xpstopdf refused all three. Copy B5 removes page 2, and MuPDF refused it. Ask the sender for a new copy.
6. A page is broken Copies C1 and C2 break the page XML, and MuPDF and xpstopdf refused both. No repair script of ours fixed them, so get a new copy.
7. The file is OpenXPS and the program is old Wikipedia says older Windows versions do not support the .oxps ending on their own. MuPDF, xpstopdf and 7-Zip opened both OpenXPS files we had.
8. One reader refuses and another does not xpstopdf refused testXLSX.xps and test_text.xps, and MuPDF and 7-Zip opened both. Try a second reader before you decide that the file is broken.

How Does an XPS File Differ From OXPS and PDF Files? One Microsoft format, its neighbors compared

An XPS file is the Microsoft XML Paper Specification file. An OXPS file is the same idea under the Ecma standard, with the .oxps ending. A PDF file is the format from Adobe that stayed the usual choice for fixed pages.

The table lists the neighbors of an XPS file. We studied XPS and OpenXPS files only. The PDF and ZIP rows come from Wikipedia and our own checks, so they are short.

XPS and its neighbors compared
Type What separates it
XPS The .xps ending of Windows Vista and Windows 7, per Wikipedia. The Microsoft namespace. 18 of our 21 files, and 16 opened in all three readers.
OXPS The .oxps ending of the Ecma standard, which Windows 8 made the default of its document writer, per Wikipedia. The openxps.org namespace. 2 of our files, and all three readers opened both.
PDF First released by Adobe in 1993, per Wikipedia. It uses a COS object database, and XPS is XML-based. We made two PDF files from our example.
ZIP The container of an XPS file. A ZIP file does not need the parts an XPS file needs, so a ZIP reader opens both and draws neither.

XPS or OXPS

Wikipedia gives the media types application/vnd.ms-xpsdocument and application/oxps. In our two OpenXPS files the page namespace reads http://schemas.openxps.org/oxps/v1.0. The start relationship of our own file ends in the same namespace followed by fixedrepresentation.

XPS or PDF

Both formats fix the layout of a page. Microsoft offered OpenXPS as an alternative to PDF in 2006, and PDF stayed the usual choice, per Wikipedia. We converted our example to PDF in two ways, and the convert part shows the results.

Which one do you have

PDF files Read the guide to PDF files for the Adobe format.
ZIP files Read the guide to ZIP files for the container.
DOCX files Read the guide to DOCX files for a Word document.
ODT files Read the guide to ODT files for an OpenDocument text file.

What Is the XPS File Format Made Of? The facts we could check, and where they came from

An XPS file stores a start relationship, a document sequence, documents, pages and resources in a ZIP package. Facts below come from our checks of 21 files and 21 damaged copies. Sources are Wikipedia, the Library of Congress, Microsoft and the test tools.

Facts about XPS files
Part What we could check
Maker Microsoft, with an initial release in October 2006, per Wikipedia.
Name XML Paper Specification, also called Open XML Paper Specification and OpenXPS. The endings are .xps and .oxps, per Wikipedia.
Standard ECMA-388, approved by the Ecma General Assembly on June 16, 2009, per Wikipedia.
Container An Open Packaging Conventions package in a ZIP file, per the Library of Congress. 20 of our 21 files start with 50 4b 03 04.
Start part A FixedDocumentSequence part, found by a relationship that ends in fixedrepresentation. 16 of our 20 ZIP files name it FixedDocumentSequence.fdseq.
Pages A FixedPage part with a width and a height. Text uses Glyphs tags and shapes use Path tags, per the Library of Congress.
Fonts and images Separate parts. Our fonts end in odttf, and 17 of 20 ZIP files have one.
Units Our pages read 816 by 1056. PyMuPDF at 96 dots per inch drew 816 by 1056 pixels, so one unit is 1/96 inch.
Media types application/vnd.ms-xpsdocument and application/oxps, per Wikipedia.
Viewer New installs of Windows 10 version 1803 do not include XPS Viewer, per Windows Central.

About the values we list

Facts about the layout come from our own tests of 21 files, and from the pages we name. The Wikipedia article is the source for the history and the standard. The Library of Congress record is the source for the structure.

We also used the Microsoft page on starting a document. It says a new package starts with an empty fixed document sequence part, and every document is a FixedDocument part inside it. A Microsoft page on the full specification could not be fetched, so we make no claim from it.

What we left out

We used no Windows machine. We did not open a file in Windows XPS Viewer, print to the XPS Document Writer, test a signature or scan a file for malware. Our readers and scripts worked on Linux, and Windows software can accept or refuse files that they treat differently.

The 10 public XPS files come from three projects, and we made 11 files with Python. Our damaged copies come from one small file and change one thing at a time. We did not compare pictures of the pages, and we did not decode print tickets or document structure parts.

Sources checked

For the format and its history, see the Wikipedia article on Open XML Paper Specification and the Library of Congress format description. For the package, see Microsoft's page on StartNewDocument. For viewers, see FileInfo.

For the viewer in Windows 10 version 1803, we used a Windows Central report. The test files come from the GhostPDL source, the dotnet/wpf source and the Apache Tika source. The main reader is the MuPDF project.

Frequently Asked Questions About XPS Files

What is an XPS file?

An XPS file is a fixed-layout document made by Microsoft. It stores the text, fonts, images and shapes of every page in a ZIP package of XML parts. A page looks the same on every screen and printer. The name stands for XML Paper Specification.

What does XPS stand for?

XPS stands for XML Paper Specification. Microsoft developed it, with an initial release in October 2006. Ecma International adopted it as ECMA-388, and the standard is also called Open XML Paper Specification, or OpenXPS.

How do I open an XPS file?

On Windows, double-click it in XPS Viewer. New installs of Windows 10 version 1803 do not include the viewer, and you add it under Settings, Apps and Optional features. Without it, MuPDF opened 20 of our 21 files, xpstopdf 18 and 7-Zip 20. We did not test the viewer.

Which program makes an XPS file?

A program makes one when you print to the XPS Document Writer, a virtual printer that Windows includes, per Wikipedia. Windows Vista also used XPS as its spooler format. We made our 11 test files with Python and its zipfile module.

How do I convert an XPS file to PDF?

Use xpstopdf or PyMuPDF. Both made a 2 page PDF file from our example, with the same text and a page size of 612 by 792 points. The files were 16,130 and 27,579 bytes. We did not test a route on Windows.

What is the difference between XPS and OXPS?

OXPS is the same format under the Ecma standard, with the `.oxps` ending and the openxps.org namespace. XPS is the older ending of Windows Vista and Windows 7. Wikipedia says older Windows versions do not support `.oxps` on their own. MuPDF, xpstopdf and 7-Zip opened both OpenXPS files we had.

Is XPS the same as PDF?

No. Both fix the layout of a page, but they are different formats. Adobe first released PDF in 1993, and Microsoft released XPS in 2006. PDF uses a COS object database, and XPS is XML-based in a ZIP package, per Wikipedia.

Is an XPS file safe to open?

Listing the parts of one starts nothing. Our 20 ZIP files contained no script parts, only pages, fonts, images and labels. Even so, a viewer parses fonts and images, and we did not scan for malware. Open files from sources you trust, and work on a copy.

Why will my XPS file not open?

One cause is a file that is not a ZIP file, as with our OLE file named .xps. A text mode transfer, a cut file, a missing part or a broken page also stop it, and so does a missing viewer. Check the first bytes, then try a second reader.

Can I open an XPS file on a Mac or Linux?

We tested Linux only, with MuPDF, xpstopdf and 7-Zip. All three are free programs, and all three opened 18 of our 21 files. We did not test a Mac. Convert a copy to PDF if you need a format that more programs know.

How do I get the text or images out of an XPS file?

PyMuPDF reads the text of every page, and it gave 114 characters for our example. The images are parts of the ZIP package, so `unzip` pulls one out, as in our example. Ours was a PNG of 64 by 48 pixels.

How can I check whether an XPS file is damaged?

Copy it, read the first bytes and test the ZIP. Then follow the start relationship to the pages and check the resources. Finish with two readers, because our script printed OK on a copy that MuPDF and 7-Zip treated another way.

Still Stuck With an XPS File? Where to go next, depending on what went wrong

Your XPS file will not open

Read the first bytes and use the check script. The cause list names what to try in order.

You do not know the kind

The kinds table names the kind, and the neighbors name the formats that look alike.

Is it a PDF file? The PDF file overview covers the Adobe format.

Is it an archive? The ZIP file overview covers the compressed archive.

Is it a Word document? The DOCX file overview covers the Word format.

Is it a spreadsheet? The XLS file overview covers the Excel 97 to 2003 workbook.

Is it a file type you do not know? Browse the file extension resource library, or send it on the submit a file type page.

Do you need the format facts? Read the format part for the layout and the sources of XPS files.