この簡単なチュートリアルでは、C++を使用してPowerPointプレゼンテーションをXPSに変換する方法について説明します。 XPSは広く使用されている一般的な形式であり、単純なC ++コードを使用すると、相互運用なしでPPTXをC++のXPSに変換できます。
C++でPowerPointをXPSに変換する手順
- Aspose.Slides for C++NuGetパッケージを使用する
- Aspose::Slidesへの参照と名前空間のエクスポートを含める
- Presentationクラスインスタンスを使用してPPTXをXPSに保存するためのプレゼンテーションファイルをロードします
- Saveメソッドを使用して、SaveFormatを設定することにより、C++でPPTXをXPSに変換します。
Aspose.Slides for C ++ APIを使用すると、MicrosoftInteropやMicrosoftPowerPointに依存せずに、C++でPPTをXPSに簡単に変換できます。
C++でPowerPointをXPSに変換するコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} | |
}; |
以前は、C++を使用してPPTXを保護する方法について説明しました。ただし、上記の例では、PPTXプレゼンテーションをC++でXPS形式にエクスポートする方法を見てきました。上記のサンプルコードは、VisualStudioでサポートされているC++アプリケーションで使用できます。