XpsRollup is a sample program that combines multiple XPS documents into a single document and renames the resource parts to prevent part name conflicts. This sample provides an excellent illustration for how to identify and navigate the component parts of an XPS document.
This topic contains the following sections:
- Downloading the Sample
- Building the Sample
- Running the Sample
- Additional Information
- Related topics
The XpsRollup sample program reads one or more XPS documents and uses the IXpsOMPackageWriter interface to write the merged document back to a file.
The filenames of an XPS document are read from the command line, and the XPS documents are read into an IXpsOMPackage interface through the IXpsOMObjectFactory::CreatePackageFromFile method. The contents and resources of each document are found, read, then renamed and written to the output package.
The program closes the IXpsOMPackageWriter interface, which writes the merged documents to the output package as a single, merged XPS document.
Important This sample doesn't merge IXpsOMStoryFragmentsResource parts. If one of the XPS documents contains a IXpsOMStoryFragmentsResource part, you'll get an incorrect output.
|Microsoft Windows||Windows 7|
|Windows SDK||Windows 7 Platform Software Development Kit (SDK)|
|Microsoft Visual Studio||Visual Studio 2008 or later|
|Windows SDK||\Program Files\Microsoft SDKs\Windows\v7.0\samples\xps\XpsRollup|
To build the sample 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; this will 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.
To run the sample after it has been built:
- Open a Command Prompt window and navigate to the directory that contains the new executable file.
- At the command prompt, type the command as described in the Additional Information section.
As a console application, XpsRollup.exe must be run in the Command Prompt window. The command is formatted as follows:
XpsRollup output_filename input_filename [input_filename ...]
In this command,
output_filenameis the name of the new XPS document that will contain the pages and required resources of all the input files.
input_filenameis the name of an XPS document to be read and appended to the created document. The command line can contain one or more
input_filenameparameters, each separated by a space. Filenames that contain spaces must be enclosed within double quotes.
To see all of the XPS programming sample programs, see the XPS Programming Samples on MSDN Code Gallery.
- Navigate the XPS OM
- Common XPS Document Programming Tasks