This is the third part in the Dissecting XPS Series and this episode will focus on the Fixed Document parts of an XPS document. The previous part described how an XPS document is packed into a package and how we could find the actual document within it.
FixedDocument and PageContent
The FixedDocument element  is the part of the XPS document which contains the actual pages, which are represented as PageContent elements. The PageContent elements appears in the exact same order in which they should appear in the document and contains a reference to the FixedPage Part and optionally size (width and height) of the page.
The PageContent elements may also contain LinkTarget elements, which informs the XPS consumer that the page contains these named links (or anchors). This is a smart design that allows the consumer to just scan the FixedDocument Part for all links, instead of browsing through the whole XPS document and all fixed pages. The same is for Width and Height of the PageContent element, which is optional to specify at this level. Specifying the size on the PageContent element allows XPS consumers to make initial previews faster without loading the actual content.
The example below shows the FixedDocument Part, normally having the extension of .fdoc, of the XPS specification document , and you can see how the PageContent element refers to the FixedPage Parts and how the LinkTargets are used to show the links in each part. The FixedPage Parts are normally located in files ending with the .fpage extension and the Source attribute is showing the relative path to the file.
1: FixedDocument xmlns="http://schemas.microsoft.com/xps/2005/06">
2: PageContent Source="Pages/1.fpage">
4: LinkTarget Name="PG_1_LNK_1812"/>
7: PageContent Source="Pages/2.fpage">
9: PageContent Source="Pages/3.fpage">
11: LinkTarget Name="PG_3_LNK_1813"/>
The FixedPage Part
The FixedPage Part, representing the actual page, has a FixedPage element as root and that element contains all the other elements that is making up the page. The FixedPage element has some important attributes that are required;
- The size of the page must be specified, using the Width and Height attributes
- The default language must be specified, using the xml:lang attribute. The language is specified according to RFC 3066 .
1: FixedPage xmlns="http://schemas.microsoft.com/xps/2005/06"
The size of the page, the Width and Height, are specified using a real number in units of the effective coordinate space. By default the coordinate space is defined with units of 1/96" . This size is the actual size of the page, compared to the size at the PageContent element which only are advisory.
The element also have two optional attributes that are important for viewing and especially printing, called BleedBox and ContentBox. The ContentBox, which is recommended to use, is used to defined an area within or equal to the FixedPage area defined by the (0,0,Width,Height) coordinates and specifies the area that contains all content that must be seen when printing or viewing the page. The BleedBox on the other hand defines a surrounding area of the FixedPage and is used when you,for example, have crop marks and other notations not used in the final output of a document but is used after printing as an aid for cutting or folding. If you are interested in this read through section 3.3 of the XPS Specification .
The FixedPage element optionally also have a Name attribute to identify the page when for example hyperlinking to it.
Next time we will look into how the content is marked up using the Path, Glyphs and Canvas elements that are used in the PageContent element.