How to Covert PowerPoint Presentation to XPS Using C++

In this simple tutorial, we will walk you through how to convert PowerPoint presentation to XPS using C++. XPS is popular widely used popular format and using simple C++ code, you can convert PPTX to XPS in C++ without interop.

Steps to Convert PowerPoint to XPS in C++

  1. Use Aspose.Slides for C++ NuGet package
  2. include reference to Aspose::Slides and Export namespaces
  3. Load the presentation file for saving PPTX to XPS using Presentation class instance
  4. Use the Save method to convert PPTX to XPS in C++ by setting SaveFormat

You can easily convert PPT to XPS in C++ using Aspose.Slides for C++ API with no reliance on Microsoft Interop or Microsoft PowerPoint.

Code to Convert PowerPoint to XPS in C++

#pragma once
#include <DOM/Presentation.h>
#include <Util/License.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace System;
class ConvertXPSEx {
public:
static void ConvertToXps()
{
//Set Aspose license before securing PowerPoint presentation
//using Aspose.Slides for C++
const String LicPath = u"Aspose.Total.NET.lic";
SharedPtr<License> lic = MakeObject<License>();
lic->SetLicense(LicPath);
// The path to the documents directory.
const String outputXPS = u"ConvertToXps_output.xps";
const String SourcePresentation = u"Input.pptx";
//Instantiate Presentation class to load PPTX for exporting to XPS
SharedPtr<Presentation> pres = MakeObject<Presentation>(SourcePresentation);
//Save the presentation to output XPS format
pres->Save(outputXPS, SaveFormat::Xps);
}
};

Previously, we explored How to Protect PPTX using C++. However, in the above example we have seen how to export PPTX presentation to XPS format in C++. The above sample code an be used in C++ applications supported by Visual Studio.

 English