Logo
PREGNANCY
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
 
 
Windows 7

Visual Basic 2010 : Manipulating Documents and Media - Viewing XPS Documents

7/6/2011 11:39:40 AM
Starting from Windows Vista, Microsoft introduced a new file format known as XPS that is a portable file format for documents and is useful because you can share documents without the of having installed the application that generated that kind of document because you simply need a viewer. WPF offers full support for XPS documents, also offering a DocumentViewer control that enables developers to embed XPS viewing functionalities in their applications. Support for XPS documents is provided by the ReachFramework.dll assembly (so you need to add a reference) that exposes the System.Windows.Xps.Packaging namespace. For code, you simply drag the DocumentViewer control from the toolbox onto the Window surface so that the generated XAML looks like the following:
<DocumentViewer Name="DocumentViewer1" />

At design time you can notice how such control offers a number of buttons for adjusting the document layout, for zooming and printing. XPS documents are fixed documents differently from flow documents, so you need to create an instance of the XpsDocument class and get a fixed sequence of sheets to be assigned to the Document property of the viewer, as demonstrated in the following code snippet that enables loading and presenting an XPS document:

Dim documentName As String = "C:\MyDoc.xps"
Dim xpsDoc As XpsDocument

xpsDoc = New XpsDocument(documentName, IO.FileAccess.ReadWrite)
DocumentViewer1.Document = xpsDoc.GetFixedDocumentSequence

Figure 1 shows a sample XPS document opened in the DocumentViewer control.

Figure 1. Viewing XPS documents through the DocumentViewer control.

So with a few steps you can embed XPS functionalities in your applications.

Other -----------------
- Visual Basic 2010 : Manipulating Documents and Media - Manipulating Documents
- Visual Basic 2010 : Manipulating Documents and Media - Viewing Images & Playing Media
- Automating the Windows 7 Installation : Deploying Unattended Installations (part 4) - Microsoft Assessment and Planning Toolkit
- Automating the Windows 7 Installation : Deploying Unattended Installations (part 3) - Installing the WDS Server Components
- Automating the Windows 7 Installation : Deploying Unattended Installations (part 2) - Using Windows System Image Manager to Create Answer Files
- Automating the Windows 7 Installation : Deploying Unattended Installations (part 1)
- Microsoft Visio 2010 : Understanding Organization Charts & Building an Organization Chart by Hand
- Microsoft Visio 2010 : Creating Swimlane Diagrams
- Microsoft Excel 2010 : Editing Chart Data
- Microsoft Excel 2010 : Changing the Chart Background & Enhancing a Chart
- Microsoft Excel 2010 : Formatting Chart Text & Formatting Line and Bar Charts
- Visual Studio 2010 : Building the Windows Container (part 3) - Creating a Multiple Document Interface
- Visual Studio 2010 : Building the Windows Container (part 2) - Adding menus and toolbars
- Visual Studio 2010 : Building the Windows Container (part 1) - Setting common form properties & Creating dialog boxes
- Microsoft Visio 2010 : Adding Labels to Flowcharts & Understanding Swimlane Diagrams
- Microsoft Visio 2010 : Selecting a Flowchart Type & Creating Flowcharts
- Automating the Windows 7 Installation : Choosing Automated Deployment Options (part 3) - An Overview of the System Preparation Tool and Disk Imaging
- Automating the Windows 7 Installation : Choosing Automated Deployment Options (part 2)
- Automating the Windows 7 Installation : Choosing Automated Deployment Options (part 1) - An Overview of the Microsoft Deployment Toolkit 2010
- Advanced .NET Framework with VB 2010 : Coding Attributes - Reflecting Attributes
 
 
Most view of day
- Adobe Flash Catalyst CS5 : Round-trip editing with Adobe Illustrator and Adobe Photoshop
- Windows Server 2008 R2 high-availability and recovery features : Installing and Administering Windows Backup (part 2) - Creating and managing backup jobs
- Windows Server 2012 : Provisioning and managing shared storage (part 6) - Managing shared storage
- Microsoft Project 2010 : Linking Tasks (part 3) - Using the Start-to-Start Relationship,Using the Finish-to-Finish Relationship
- Windows Server 2012 Administration : Windows Server 2012 Active Directory Groups
- SQL Server 2008 R2 : Performance Monitoring Tools (part 9) - Creating an Extended Events Session
- Microsoft Dynamics AX 2009 : Integration with Microsoft Office - Exporting data to Microsoft Project
- SQL Server 2008 R2 : Performance Monitoring Tools (part 12) - Viewing Data Collector Set Results in Performance Monitor
- BizTalk Server 2009 Operations : Maintaining the BizTalk Group (part 1) - SQL Agent Job Configuration
- Windows Server 2003 on HP ProLiant Servers : Security Planning and Design (part 2) - Account Lockout
Top 10
- Windows Phone 8 : Configuring Mailbox Settings (part 5) - Configuring Automatic Replies
- Windows Phone 8 : Configuring Mailbox Settings (part 4) - Lightening the Display,Changing the Mailbox Sync Settings
- Windows Phone 8 : Configuring Mailbox Settings (part 3) - Message Signatures, Blind CCing Yourself
- Windows Phone 8 : Configuring Mailbox Settings (part 2) - Unlinking Mailboxes, Conversation View
- Windows Phone 8 : Configuring Mailbox Settings (part 1) - Linking Mailboxes
- Managing Windows Server 2012 Systems : Configuring Roles, Role Services, and Features (part 6) - Tracking installed roles, role services, and features
- Managing Windows Server 2012 Systems : Configuring Roles, Role Services, and Features (part 5) - Installing components at the prompt
- Managing Windows Server 2012 Systems : Configuring Roles, Role Services, and Features (part 4) - Managing server binaries
- Managing Windows Server 2012 Systems : Configuring Roles, Role Services, and Features (part 3) - Adding server roles and features
- Managing Windows Server 2012 Systems : Configuring Roles, Role Services, and Features (part 2) - Installing components with Server Manager - Viewing configured roles and role services
 
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro