Create or Edit XPS Documents Programmatically in C++

Create PS EPS XPS Documents in C++

Aspose.Page for C++ is a valuable addition to Aspose.Page Product Family which is developed for manipulation of PostScript (PS/EPS) and XPS documents using C++. Aspose.Page for C++ is a native C++ library for creating new XPS files as well as modifying and converting the existing PostScript and XPS documents programmatically. The API also lets you work with the pages and elements such as canvases and glyphs in the XPS documents. Furthermore, it supports converting the documents to PDF and raster images. This article demonstrates how to perform the following operations related to XPS documents using Aspose.Page for C++.

  • Create a new XPS document in C++
  • Edit an existing XPS document in C++
  • Add a page or document to an XPS document in C++

Installation of XPS API for C++

Aspose.Page for C++ is hosted on the NuGet as well as available as downloadable binaries. The downloadable package also contains a C++ console application containing the source code of basic examples.

Create an XPS Document in C++

The following are the simple steps to create an XPS document containing text and image using Aspose.Page for C++.

The following code sample shows how to create an XPS document in C++.

Output

Edit PS EPS XPS Document C++

Edit an XPS Document in C++

The following are the steps to edit an existing XPS document:

  • Create an object of the XpsDocument class and initialize it with the XPS document’s path.
  • Access the document’s elements using the XpsDocument object.
  • Save the updated document using the Save method.

The following code sample shows how to edit an existing XPS document in C++.

Add Page and Document to XPS in C++

Aspose.Page for C++ also lets you add pages as well as multiple documents in an XPS document. The following are the steps to create a new XPS document and add an additional page and document.

  • Create an object of the XpsDocument class.
  • Use AddPage and AddDocument methods to add page and document respectively.
  • Use the SelectActiveDocument method to select the active document for processing.
  • Add text or image to the document.
  • Save the document.

The following code sample shows how to add additional pages and documents to XPS using C++.

Learn more about Aspose.Page for C++

You can learn more about Aspose.Page for C++ using the documentation and the source code examples available on GitHub.