Dalam tutorial sederhana ini, kami akan memandu Anda melalui cara mengubah presentasi PowerPoint ke XPS menggunakan C++. XPS adalah format populer yang banyak digunakan dan menggunakan kode C++ sederhana, Anda dapat mengonversi PPTX ke XPS dalam C++ tanpa interop.
Langkah-langkah untuk Mengkonversi PowerPoint ke XPS di C++
- Gunakan Aspose.Slides for C++ paket NuGet
- sertakan referensi ke Aspose::Slides dan Ekspor ruang nama
- Muat file presentasi untuk menyimpan PPTX ke XPS menggunakan instance kelas Presentation
- Gunakan metode Simpan untuk mengonversi PPTX ke XPS di C++ dengan mengatur SaveFormat
Anda dapat dengan mudah mengonversi PPT ke XPS di C++ menggunakan Aspose.Slides for C++ API tanpa bergantung pada Microsoft Interop atau Microsoft PowerPoint.
Kode untuk Mengonversi PowerPoint ke XPS di 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); | |
} | |
}; |
Sebelumnya, kami menjelajahi Cara Melindungi PPTX menggunakan C++. Namun, pada contoh di atas kita telah melihat cara mengekspor presentasi PPTX ke format XPS di C++. Contoh kode di atas dapat digunakan dalam aplikasi C++ yang didukung oleh Visual Studio.