XpsOnePage

The XpsOnePage sample programs demonstrate how to create an XPS document with one blank page and write it to a file. This sample includes two programs: one creates an XPS OM and then writes it to a file as an XPS document and the other uses the IXpsOMPackageWriter interface to write the XPS document as a file.

This topic contains the following sections:

XpsOnePage Description

The XpsOnePage program creates an IXpsOMObjectFactory interface and passes it to the Common_CreateABlankXpsOM method to create the document. The Common_CreateABlankXpsOM creates an XPS OM that contains each of the components required to make a minimal XPS document. The program calls the IXpsOMPackage::WriteToFile method to write the completed XPS OM to a file as an XPS document.

XpsOnePagePW Description

The XpsOnePagePW program creates an IXpsOMObjectFactory interface and passes it to the CreateABlankXpsOMUsingPW method to create the document. The CreateABlankXpsOMUsingPW creates an IXpsOMPackageWriter interface that incrementally writes the pages to an XPS document file. This example also adds an IXpsOMPrintTicketResource to the fixed document sequence of the XPS document.

Requirements

ProductVersion
Microsoft WindowsWindows 7
Windows SDKWindows 7 Platform Software Development Kit (SDK)
Microsoft Visual StudioVisual Studio 2008 or later

 

Downloading the Sample

LocationPath/URL
Code Galleryhttp://go.microsoft.com/fwlink/p/?linkid=184272

 

Building the Sample

To build the sample by using Visual Studio:

  1. Open Windows Explorer and navigate to the directory that contains the sample code files.

  2. Open the XpsOnePage.sln or XpsOnePagePW.sln file in Visual Studio by double-clicking the file icon.

    Note  The solution file in this sample is compatible with Visual Studio 2008 and later versions of Visual Studio.

  3. In the Build menu, select Build Solution.

The application will be built in the default \Debug or \Release directory.

Running the Sample

To run the sample after it has been built:

  1. Use Windows Explorer or the Command Prompt window to navigate to the directory that contains the new executable file.
  2. Run the program, either from the Command Prompt window or from Windows Explorer.
    • In the Command Prompt window, type XpsOnePage.exe or XpsOnePagePW.exe, depending on the program that was built.
    • In Windows Explorer, double-click the XpsOnePage.exe or the XpsOnePagePW.exe icon, depending on the program that was built.

Additional Information

XpsOnePage.exe creates a single-page XPS document and writes the document to OnePageSampleDoc.xps in the same folder as the source code.

XpsOnePagePW.exe creates a single-page XPS document and writes the document to OnePageSampleDocPW.xps in the same folder as the source code.

To see all of the XPS programming sample programs, see the XPS Programming Samples on MSDN Code Gallery.

Related topics

IOpcPartUri
IXpsOMDocument
IXpsOMDocumentCollection
IXpsOMDocumentSequence
IXpsOMObjectFactory
IXpsOMPackage
IXpsOMPackageWriter
IXpsOMPage
IXpsOMPageReference
IXpsOMPageReferenceCollection
IXpsOMPrintTicketResource
Common XPS Document Programming Tasks

 

 

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.