This post is migrated from previous hosting provider. There are still some issues with old posts. Please make a comment on this post with any issues.

Dissecting XPS - part 3 - the Fixed Document

Tags: XPS

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.

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

No Comments

  • Wictor said

    This has crossed my mind more than once, there is no out of the box solution. Since XPS is a fixed page document format you have to calculate the pagination, table sizes etc in the docx file. Maybe there is some way to print through the XPS Documenter?

  • Girl said

    Great work Wictor..After reading this XPS looks easy.... Pls explain more on Width="816" Height="1056"> ...How it calculated...I have tiff image after creating the XPS document the complete tiff image is not dispplayed.

Comments have been disabled for this content.

AWS Tracker

About Wictor...

Wictor Wilén is a Director and SharePoint Architect working at Connecta AB. Wictor has achieved the Microsoft Certified Architect (MCA) - SharePoint 2010, Microsoft Certified Solutions Master (MCSM) - SharePoint  and Microsoft Certified Master (MCM) - SharePoint 2010 certifications. He has also been awarded Microsoft Most Valuable Professional (MVP) for four consecutive years.

And a word from our sponsors...

SharePoint 2010 Web Parts in Action