Share via


DocumentViewer in Internet Explorer Sample

The DocViewerInIE sample shows how to display documents in a DocumentViewer control hosted in Microsoft Internet Explorer.

The sample runs as a in a protected sandbox with limited "Internet Zone" permissions. When executed, the DocViewerInIE sample invokes Internet Explorer to display a hosted DocumentViewer control. When "File | Open..." is selected, a "File Open..." dialog is displayed enabling the user to browse and select an XpsDocument file to open (a sample XPS document is provided). When a document is opened, its content is displayed in the DocumentViewer control that is hosted in Internet Explorer.

The DocViewerInIE sample source code consists of four files:

  • App.xaml - XAML resources for the application (none in this sample).

  • App.xaml.cs - Code-behind for creating and displaying the application window.

  • Page1.xaml - XAML declarations that define the elements of the Internet Explorer page: main menu, menu commands, and DocumentViewer control.

  • Page1.xaml.cs - Code-behind supporting the user interface for the hosted page commands.

A project file, temporary certificate key, and sample XPS document are also provided. XAML browser applications (XBAPs) must be digitally signed. The DocViewerInIE sample provides a temporary signed certificate key set with a blank password. If Visual Studio prompts for a password, leave the password field blank and just click "OK" to continue. For more information about building and running DocViewerInIE, see the "ReadMe.txt" file provided with the sample source code.

This sample demonstrates a specific feature of the Windows Presentation Foundation (WPF) and, consequently, does not follow application development best practices. For comprehensive coverage of WPF and Microsoft .NET Framework application development best practices, refer to the following as appropriate:

Accessibility - Accessibility Best Practices

Security - WPF Security

Localization - WPF Globalization and Localization Overview

Download sample

Building the Sample

Procedure Title

  1. Install the Windows Software Development Kit (SDK) and open its build environment command window. On the Start menu, point to All Programs, Microsoft Windows SDK, and then click CMD Shell.

  2. Download the sample, usually from the software development kit (SDK) documentation, to your hard disk drive.

  3. To build the sample from the build environment command window, go to the source directory of the sample. At the command prompt, type MSBUILD.

  4. To build the sample in Microsoft Visual Studio 2005, load the sample solution or project file and then press CTRL+SHIFT+B.

Running the Sample

  • To run the compiled sample with debugging in Visual Studio 2005, press F5.

  • To run the sample from a CMD Shell command window, execute the .exe file located in the source folder of the sample.

See Also

Other Resources

Documents in Windows Presentation Foundation
DocumentViewer XPS Sample
DocumentViewer with Annotations XML-Store Sample
DocumentViewer with Annotations XPS Store Sample
Creating an XPS Document Sample
Saving an XPS Document Sample
Printing an XPS Document