
PowerPoint 演示文稿具有包含有关演示文稿的详细信息的属性,例如标题、作者姓名、主题和识别文档主题或内容的关键字等。指定演示文稿属性的相关值非常重要,因为它们有助于识别演示文稿。而且,演示文稿中的单个幻灯片具有与之相关的属性,例如高度、宽度、方向、演示文稿中的幻灯片索引、尺寸类型等。Aspose.Slides Cloud 使您能够以编程方式设置 PPTX 保护属性。
快速提示
使用以下命令识别当前托管的 Aspose.Slides Cloud API 版本,
curl -X GET "https://api.aspose.cloud/v3.0/slides/info" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"
响应主体
{ "name": "Aspose.Slides for Cloud", "version": "21.1.0" }
现在我们将在本博客中阐明以下主题。
获取幻灯片属性
Aspose.Slides Cloud 提供了使用 cURL 命令获取幻灯片属性的功能,同时,您可以尝试使用特定语言的编程 SDK 来满足您的需求。
cURL 命令
curl -X GET "https://api.aspose.cloud/v3.0/slides/input.pptx/slideProperties" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"
请求 URL
https://api.aspose.cloud/v3.0/slides/input.pptx/slideProperties
响应主体
{ "firstSlideNumber": **1**, "orientation": "Landscape", "sizeType": "Widescreen", "width": **960**, "height": **540**, "selfUri": { "href": "https://api.aspose.cloud/v3.0/slides/input.pptx/slideProperties", "relation": "self" } }
C# .NET
// 完整示例可以在 https://github.com/aspose-slides-cloud/aspose-slides-cloud-dotnet 找到。
string MyAppKey = "xxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/
try
{
// 实例化 SlidesAPI 对象
Aspose.Slides.Cloud.Sdk.SlidesApi slidesApi = new Aspose.Slides.Cloud.Sdk.SlidesApi(Client_ID, Client_Secret);
// 创建 GetSlidesSlidePropertiesRequest 对象并提供输入 PPTX 参考
GetSlidesSlidePropertiesRequest request = new GetSlidesSlidePropertiesRequest { Name = "input.pptx" };
// 读取幻灯片属性
SlideProperties slideProperties = slidesApi.GetSlidesSlideProperties(request);
// 显示第一张幻灯片的编号详情
Console.WriteLine(slideProperties.FirstSlideNumber);
// 打印幻灯片的方向细节
Console.WriteLine(slideProperties.Orientation);
// 打印滑梯的高度细节
Console.WriteLine(slideProperties.Height);
// 打印幻灯片的宽度详细信息
Console.WriteLine(slideProperties.Width);
// 打印与 scaleType 相关的信息
Console.WriteLine(slideProperties.ScaleType);
}
catch (Exception e)
{
Console.WriteLine("Exception while calling Api: " + e.ToString());
}
设置 PPTX 幻灯片属性
然而,Aspose.Slides Cloud 完全能够设置 PowerPoint 幻灯片的属性,在以下部分中,我们已解释相关步骤。
cURL 命令
curl -X PUT "https://api.aspose.cloud/v3.0/slides/input.pptx/slideProperties" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>" \
-H "Content-Type: application/json" \
-d "{ \"FirstSlideNumber\": 0, \"Orientation\": \"Portrait\", \"ScaleType\": \"DoNotScale\", \"SizeType\": \"OnScreen\", \"Width\": 600, \"Height\": 900, \"SelfUri\": { \"Href\": \"https://api.aspose.cloud/v3.0/slides/input.pptx/slideProperties\", \"Relation\": \"self\", \"LinkType\": \"\", \"Title\": \"Hello\" }, \"AlternateLinks\": [ { \"Href\": \"string\", \"Relation\": \"string\", \"LinkType\": \"string\", \"Title\": \"string\" } ]}"
C# .NET
// 请访问以下链接以获取完整的源代码 https://github.com/aspose-slides-cloud/aspose-slides-cloud-dotnet
try
{
String Client_ID = "xxxxxxxx-1c8e-4ea4-a948-3857547232fa";
String Client_Secret = "xxxxxxxx237f013e329cdf5694cc96a";
// 实例化 SlidesAPI 对象
Aspose.Slides.Cloud.Sdk.SlidesApi slidesApi = new Aspose.Slides.Cloud.Sdk.SlidesApi(Client_ID, Client_Secret);
// 创建 PutSlidesSlidePropertiesRequest 对象并提供输入 PPTX 作为参数
PutSlidesSlidePropertiesRequest request = new PutSlidesSlidePropertiesRequest {
// speicfy input PowerPoint presentation
Name = "input.pptx",
Dto = new SlideProperties {
Width = 900,
Height = 600,
Orientation = SlideProperties.OrientationEnum.Portrait,
ScaleType = SlideProperties.ScaleTypeEnum.DoNotScale,
SizeType = SlideProperties.SizeTypeEnum.OnScreen,
}
};
SlideProperties response = slidesApi.PutSlidesSlideProperties(request);
// 读取幻灯片的宽度属性
Console.WriteLine(response.Width);
// 读取幻灯片的高度属性
Console.WriteLine(response.Height);
}
catch (Exception e)
{
Console.WriteLine("Exception while calling Api: " + e.ToString());
}
获取幻灯片保护属性
API 的 GetSlidesProtectionProperties 方法提供读取演示文稿文档保护属性的功能。
curl -X GET "https://api.aspose.cloud/v3.0/slides/input.pptx/protectionProperties" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"
C# .NET
// 请访问以下链接以获取完整源代码 https://github.com/aspose-slides-cloud/aspose-slides-cloud-dotnet
try
{
String Client_ID = "xxxxxxx-1c8e-4ea4-a948-3857547232fa";
String Client_Secret = "xxxxxxxx237f013e329cdf5694cc96a";
// 实例化 SlidesAPI 对象
SlidesApi slidesApi = new SlidesApi(Client_ID, Client_Secret);
// 创建 PutSlidesSlidePropertiesRequest 对象并提供输入 PPTX 作为参数
GetSlidesProtectionPropertiesRequest request = new GetSlidesProtectionPropertiesRequest
{
// 指定输入PPT演示文稿
Name = "input.pptx",
};
ProtectionProperties slideProperties = slidesApi.GetSlidesProtectionProperties(request);
// 读取幻灯片的宽度属性
Console.WriteLine("Encrypted Document Properties = "+slideProperties.EncryptDocumentProperties);
Console.WriteLine("Read Only Recommended = "+slideProperties.ReadOnlyRecommended);
Console.WriteLine("Self URi = " + slideProperties.SelfUri);
}
catch (Exception e)
{
Console.WriteLine("Exception while calling Api: " + e.ToString());
}
废弃的方法
PUT fromHtml 方法已被弃用,将在 21.4 版本中删除。请使用 POST fromHtml 方法创建演示文稿并向其添加新幻灯片。
slideSize 资源已弃用,将在 21.4 版本中删除。请改用 slideProperties 资源。
结论
在本文中,我们探索了 Aspose.Slides Cloud 设置 PPTX 保护属性、获取幻灯片保护属性、使用 C# .NET 获取幻灯片属性以及 cURL 命令的能力。您可以轻松地从 GitHub 下载 Aspose.Slides Cloud SDK for .NET 的完整源代码。要了解有关 SDK 能力的更多信息,请查看 Developer Guide。