C++: Convert PowerPoint to XPS

PowerPoint is a popular format used to create presentations, training materials, business reports, etc. However, it has certain disadvantages, such as not being secure enough or having possible compatibility issues on different devices/software. While XPS, also known as XML Paper Specification, is a more secure and compatible file format suitable for high quality printing and fast transfer. As a result, there are many people who may choose to convert their PowerPoint files to XPS format. In this article, you will learn how to programmatically convert a PowerPoint Presentation to XPS using Spire.Presentation for C++.

Install Spire.Presentation for C++

There are two ways to integrate Spire.Presentation for C++ into your application. One way is to install it through NuGet, and the other way is to download the package from our website and copy the libraries into your program. Installation via NuGet is simpler and more recommended. You can find more details by visiting the following link.

Integrate Spire.Presentation for C++ in a C++ Application

Convert PowerPoint to XPS in C++

It's fairly simple to convert a PowerPoint presentation to an XPS file using Spire.Presentation for C++. You just need to load a sample PowerPoint document and then save it as XPS format using Workbook->SaveToFile(LPCWSTR_S fileName, FileFormat::XPS) method. The following are the detailed steps.

  • Create a Presentation instance.
  • Load a PowerPoint document using Presentation->LoadFromFile() method.
  • Save the document to an XPS file using Presentation->SaveToFile(LPCWSTR_S fileName, FileFormat::XPS) method.
  • C++
#include "Spire.Presentation.o.h"

using namespace std;
using namespace Spire::Presentation;

int main()
{
	//Specify the input and output file paths
	std::wstring inputFile = L"Data\\input.pptx";
	std::wstring outputFile = L"ToXPS.xps";

	//Create a Presentation instance
	intrusive_ptr<Presentation> presentation = new Presentation();

	//Load a sample PowerPoint document 
	presentation->LoadFromFile(inputFile.c_str());

	//Save the document as an XPS file
	presentation->SaveToFile(outputFile.c_str(), FileFormat::XPS);

}

C++: Convert PowerPoint to XPS

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.