Document Services


The Longhorn platform provides extensive services that support a better online document viewing experience. There are two main services: a control designed for viewing, paginating, and navigating through the content of a document, and layout services designed to enhance the reading experience.

PageViewer Control

You use the PageViewer control when you want to display a document to the user for online viewing. The PageViewer control provides pagination and page navigation functionality. The control automatically formats the document s content into separate pages. The user can directly navigate to different pages using the controls provided by the page viewer.

Pagination and Navigation

Traditionally, online content, such as Web pages, was continuous. A user interface provided scroll bars to allow you to view content that couldn t fit in the visible area. In effect, you would scroll the view window to the position in the document you wished to see.

With pagination, you split the content of the document into one or more individual pages, similar to a book. The Longhorn platform provides support for paginated content by including several controls that help you display and navigate through content displayed as discrete pages. In addition, Longhorn provides a pagination application programming interface (API) to extend these capabilities and provide rich pagination support for custom pagination applications.

The PageViewer control is actually a complex control built from smaller controls using control composition techniques I ve previously described. The PageViewer control uses the PageSource and the PageElement controls to provide its pagination functionality. The PageSource control breaks and formats the content across pages. The PageElement control renders a single page. The PageViewer control also uses the PageBar control to allow you to navigate through the pages.

Using the PageViewer control is very simple. To display a known document, you can use it as shown in the following code. Of course, you can hook up event handlers and change the source document to cause the page viewer to display different documents.

 <Border 
xmlns="http://schemas.microsoft.com/2003/xaml"
xmlns:def="Definition"
Background="BlanchedAlmond"
>
<PageViewer Source="AuthorsandPublishers.xaml" />
</Border>

Figure 3-17 shows the page viewer hosted in a browser window displaying its document. Note the page navigation controls at the top of the document.

click to expand
Figure 3-17: The PageViewer control

Document Layout Services

Longhorn also provides document layout services designed to make the reading experience better. Longhorn contains support for two new types of documents:

  • Adaptive flow documents

  • Fixed layout documents

These new document formats allow developers to provide their applications users a better document reading experience.

Adaptive flow documents use specialized markup elements that declare that a document should be Adaptive. Longhorn automatically optimizes an adaptive document to best use the available screen space and provide the best reading experience for the user based on the capabilities or limitations of his or her system.

For example, the user might have one of the recently introduced 16-by-9 aspect ratio wide-screen displays. It s very difficult to read a line of text that spans a lengthy horizontal line. Depending on the width of the window, an adaptive document might divide the text into two, three, or more columns , thus reducing the effort for a user to scan a text line.

In another example, a document might contain an image and text that flows around the image. As you shrink the size of the document s window in a nonadaptive document, the image remains a fixed size and you see less and less of the text. An adaptive document could shrink the image when it determines that insufficient text is visible in the window. This allows the reader to still get a general idea of what the image portrays but continue to read the text in the context of the image. In a smaller window, seeing every pixel of an image is likely to be less important and useful to the reader than being able to read more text. An alternative, such as separating the image and surrounding text onto separate pages, defeats the intent of the document s author, which was to present the text and image together in context.

Fixed layout documents appear the same every time, regardless of the viewer s screen size, window size, or output device. You create a fixed layout document using specialized markup elements or by printing a document using a Microsoft Windows Vector Graphics (WVG) printer driver.

Adaptive Layout Documents

In an adaptive layout document, you supply key preferences in the root-level markup. Longhorn then can render the document in a way that makes best use of the window area and enhances its readability. Longhorn automatically determines the optimum width and number of columns for a page, ideal sizes for all text elements, optimum sizes and positions for all figures, and the widths of margins and gutters to give the best overall presentation of the content.

Producing an Adaptive Layout Document

To create an adaptive layout document, use declarative markup similar to the following:

 <Border 
xmlns="http://schemas.microsoft.com/2003/xaml"
xmlns:def="Definition"
Background="BlanchedAlmond"
>
<AdaptiveMetricsContext ColumnPreference="Medium"
FontFamily="Arial">
<TextPanel Background="white">
<Section>
<Heading OutlineLevel="1">Adaptive Layout Example</Heading>
<Paragraph>
This example shows the advanced capabilities of Adaptive Flow Layout. Lorem ips um dolor sit amet, consectetuer ad ipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad mini m veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut ali quip ex ea commodo consequat. D uis autem vel eum iriure.</Paragraph>
<Paragraph>
<Image TextPanel.FlowBehavior="Figure" Source="picture1.jpg"
TextPanel.Emphasis="Medium" />
Notice how images and text are flowed intelligently to enhance the reading experience. Lorem ipsum dolor sit amet, c onsectetuer adipiscing elit, sed diam non ummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lob ortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure.
</Paragraph>
<Paragraph>Adaptive layout is an exciting new feature of Longhorn.
<Image TextPanel.FlowBehavior="Figure" Source="picture2.jpg"
TextPanel.Emphasis="Low" />
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nis l ut aliquip ex ea commodo consequat. Duis autem vel eum xriure.</Paragraph>
</Section>
</TextPanel>
</AdaptiveMetricsContext>
</Border>

Fixed-Layout Documents

You use a fixed-layout document to present the document contents in exactly the same layout and format, independent of the application software, hardware, and operating system used. In addition, a fixed-layout document renders identically on all output devices. A fixed-layout document is a set of objects that collectively describe the appearance of one or more pages.

Producing a Fixed-Layout Document

You can use two different techniques to produce a fixed-layout document:

  • Print a document without markup to a file using the Longhorn printer driver

  • Write a fixed-layout document using XAML

When you print a document using most Microsoft Win32 applications (for example, Microsoft Office) using the Longhorn printer driver, the printer driver will create an XAML file that contains markup to paginate and position each character, image, or vector graphic in the printed document.

You can choose to output the document as a markup file directly or to include the markup file inside a container. When you select container output, you can also apply digital rights and document protection to the document.

Alternatively, you can create XAML using an editor. The following is a skeletal example of fixed-layout document:

 <FixedPanel xmlns="http://schemas.microsoft.com/2003/xaml/" > 
<FixedPage Width="8.50in" Height="11.00in"> <!-- PAGE 1 -->
<Text FontFamily="Arial" FontSize="8.4" FixedPage.Left="1.250in"
FixedPage.Top="0.530in" FontWeight="Bold">1.</Text>
<Text FontFamily="Arial" FixedPage.Left="1.350in" FixedPage.Top="0.500in"
FontWeight="Bold" FontSize="12">Fixed Document</Text>
</FixedPage>
<FixedPage>
<Text>This is page 2</Text>
</FixedPage>
<FixedPage>
<Text>This is page 3</Text>
</FixedPage>
</FixedPanel>



Introducing Microsoft WinFX
Introducing WinFX(TM) The Application Programming Interface for the Next Generation of Microsoft Windows Code Name Longhorn (Pro Developer)
ISBN: 0735620857
EAN: 2147483647
Year: 2004
Pages: 83
Authors: Brent Rector

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net