XpsLoadModifySave

The XpsLoadModifySave sample program demonstrates how to load an XPS document from a stream and how to modify and save the document.

This topic contains the following sections:

Description

The XpsLoadModifySave sample program adds a watermark to the first page of an XPS document to demonstrate how the document can be modified. The program starts by loading the original XPS document into an XPS OM. It then navigates to the first page reference in the first fixed document of the XPS document. It creates a new canvas object, then it creates the watermark text by using a font resource from the XPS document. It adds this new canvas object, which contains the watermark text, to the page's collection of visuals, and then saves the modified XPS OM as a new 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
Windows SDK\Program Files\Microsoft SDKs\Windows\v7.0\samples\xps\XpsLoadModifySave
Code Galleryhttp://go.microsoft.com/fwlink/p/?linkid=152527

 

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. Double-click the icon for the .sln (solution) file to open the file in Visual Studio.

    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 XpsLoadModifySave.exe
    • In Windows Explorer, double-click the XpsLoadModifySave.exe icon.

Additional Information

The sample program loads the XPS file Sample1.xps, modifies it, and saves it on the desktop as SDKSample_XpsLoadModifySave.xps.

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

Related topics

IXpsOMCanvas
IXpsOMDocument
IXpsOMDocumentCollection
IXpsOMDocumentSequence
IXpsOMFontResource
IXpsOMFontResourceCollection
IXpsOMGlyphs
IXpsOMGlyphsEditor
IXpsOMObjectFactory
IXpsOMPackage
IXpsOMPage
IXpsOMPageReference
IXpsOMPageReferenceCollection
IXpsOMPartResources
IXpsOMSolidColorBrush
IXpsOMVisualCollection
XPS_POINT
Navigate the XPS OM
Common XPS Document Programming Tasks

 

 

Community Additions

ADD
Show:
© 2014 Microsoft