در این آموزش ساده، نحوه تبدیل ارائه پاورپوینت به XPS با استفاده از ++C را به شما آموزش خواهیم داد. XPS فرمت محبوب پرکاربردی است و با استفاده از کد ساده C++، میتوانید PPTX را بدون interop به XPS در C++ تبدیل کنید.
مراحل تبدیل پاورپوینت به XPS در C++
- از بسته NuGet Aspose.Slides for C++ استفاده کنید
- ارجاع به Aspose::Slides و فضاهای نام صادر کنید
- بارگیری فایل ارائه برای ذخیره PPTX در XPS با استفاده از نمونه کلاس Presentation
- از روش Save برای تبدیل PPTX به XPS در C++ با تنظیم SaveFormat استفاده کنید
با استفاده از Aspose.Slides for C++ API بدون اتکا به Microsoft Interop یا Microsoft PowerPoint به راحتی می توانید PPT را به XPS در C++ تبدیل کنید.
کد برای تبدیل پاورپوینت به XPS در 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); | |
} | |
}; |
قبلاً نحوه محافظت از PPTX با استفاده از C++ را بررسی کردیم. با این حال، در مثال بالا نحوه صادرات PPTX را به فرمت XPS در C++ مشاهده کردیم. کد نمونه بالا در برنامه های C++ که توسط ویژوال استودیو پشتیبانی می شوند استفاده می شود.