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 [1] 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 [1], 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">
   3:    PageContent.LinkTargets>
   4:     LinkTarget Name="PG_1_LNK_1812"/>
   5:    PageContent.LinkTargets>
   6:   PageContent>
   7:   PageContent Source="Pages/2.fpage">
   8:   PageContent>
   9:   PageContent Source="Pages/3.fpage">
  10:    PageContent.LinkTargets>
  11:     LinkTarget Name="PG_3_LNK_1813"/>
  12:    PageContent.LinkTargets>
  13:   PageContent>
  14:  ...
  15:  FixedDocument>

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 [2].
   1:  FixedPage xmlns="http://schemas.microsoft.com/xps/2005/06" 
   2:    xml:lang="en-us" 
   3:    Width="816" 
   4:    Height="1056">
   5:  ...
   6:  FixedPage>

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" [1]. 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 [1].

The FixedPage element optionally also have a Name attribute to identify the page when for example hyperlinking to it.

Content

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.

.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; overflow-x:visible;border:0px} .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

Further reading and references

[1] XPS Specification[2] RFC 3660 - Tags for the Identification of Languages[3] Dissecting XPS - part 1 - The basics[4] Dissecting XPS - part 2 - Inside the XPS document