Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Document Merge Sample

The Document Merge sample illustrates how to extract and merge pages from multiple XPS documents to create a new XPS document that contains the selected pages. The sample provides two example XPS documents to start with, "Chocolate.xps" and " OfficeInHealthcare.xps ". To explore how the sample operates, build the sample and then run it following these steps.

  1. When the Document Merge sample begins it displays an application window that contains a "File" menu and four rows of images to display document and page images. The thumbnail frames are organized for the following use from top to bottom.

    1. Frame 1 (top)–Thumbnail of the new document.

    2. Frame 2–Thumbnails of the new pages contained in the new document.

    3. Frame 3–Thumbnails of the pages contained in the "selected" existing XPS document (frame 4).

    4. Frame 4 (bottom)–Thumbnails of existing XPS documents opened through File | Open....

  2. Click File | Open..., select the file "Chocolate.xps", and then click Open. A thumbnail of the "Chocolate" document will appear in the bottom frame.

  3. Click File | Open..., select the file "OfficeInHealthcare.xps", and then click Open. "OfficeInHealthcare" contains a sequence to two documents. A thumbnail for each of these documents will also appear in the bottom frame.

  4. In the bottom frame, click the "Chocolate" document (with the brownish background) to select it. When a document in the bottom frame is selected, thumbnails of its pages are shown in frame 3 above it. You can click the other documents in the bottom frame to view thumbnails of the pages that they contain.

  5. The two top frames are where you compose the documents and pages for a new XPS file. Using the left mouse button, click-and-hold on the "Chocolate" document, drag it to the topmost frame, and then release the mouse button. A new document thumbnail will display in the top frame with the thumbnails of its pages displayed in frame 2. Dragging a document from the bottom frame to the top frame, copies and merges the document into the new XPS file.

  6. In the bottom frame, click the text document of "OfficeInHealthcare" to display the thumbnails of its pages in the third frame.

  7. In the third frame using the left mouse button, click-and-hold one of the document pages, drag it over one of the pages in the second frame, and then release the left mouse button. Dragging a page from the third frame to the second frame, copies and merges the page into the new document. Repeat this step to copy more pages to the new document.

  8. When you are finished adding pages and documents to the new file, click File | Save As... to specify the file name and save the new XPS document.

After a new XPS document is saved, you can see the new document in the XPS viewer by double-clicking the file in Windows Explorer.

This sample demonstrates a specific feature of the Windows Presentation Foundation (WPF) and, consequently, does not follow application development best practices. For comprehensive coverage of WPF and Microsoft .NET Framework application development best practices, refer to the following as appropriate:

Accessibility - Accessibility Best Practices

Security - WPF Security

Localization - WPF Globalization and Localization Overview

Download sample

Building the Sample

  • Install the Windows Software Development Kit (SDK) and open its build environment command window. On the Start menu, point to All Programs, Microsoft Windows SDK, and then click CMD Shell.

  • Download the sample, usually from the software development kit (SDK) documentation, to your hard disk drive.

  • To build the sample from the build environment command window, go to the source directory of the sample. At the command prompt, type MSBUILD.

  • To build the sample in Microsoft Visual Studio 2005, load the sample solution or project file and then press CTRL+SHIFT+B.

Running the Sample

  • To run the compiled sample from the build environment command window, execute the .exe file in the Bin\Debug or Bin\Release folder contained under the sample source code folder.

  • To run the compiled sample with debugging in Visual Studio 2005, press F5.

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft