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
| Product | Version |
| Microsoft Windows | Windows 7 |
| Windows SDK | Windows 7 Platform Software Development Kit (SDK) |
| Microsoft Visual Studio | Visual Studio 2008 or later |
Downloading the Sample
Building the Sample
To build the sample by using Visual Studio:
-
Open Windows Explorer and navigate to the directory that contains the sample code files.
-
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.
-
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:
- Use Windows Explorer or the Command Prompt window to navigate to the directory that contains the new executable file.
- 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.
See Also
- 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
- Using the XPS Object Model
Send comments about this topic to Microsoft
Build date: 11/17/2009