PowerPoint 文件包含提供有关演示文稿的附加信息的元数据或文档属性。其中包括演示文稿的标题、日期、作者等信息。在本文中,将学习 如何使用 C++ 访问和修改 PowerPoint 演示文稿中的属性。

如果有需要,可以进入慧都官网下载最新版Aspose.Slides for C++

目录

用于访问和修改 PowerPoint 演示文稿属性的 C++ API

PowerPoint 演示文稿中的属性类型

使用 C++ 访问 PowerPoint 演示文稿中的内置属性

使用 C++ 修改 PowerPoint 演示文稿中的内置属性

使用 C++ 在 PowerPoint 演示文稿中添加自定义属性

在 PowerPoint 演示文稿中访问和修改自定义属性

用于访问和修改 PowerPoint 演示文稿属性的 C++ API

Aspose.Slides for C++ 是一个用于处理 PowerPoint 文件的 C++ API。它无需其他软件即可创建、阅读和更新 PowerPoint 文件。此外,API 允许访问和修改 PowerPoint 演示文稿的属性。

PowerPoint 演示文稿中的属性类型

PowerPoint 演示文稿中有两种类型的属性:内置和自定义。内置属性存储有关演示文稿的一般信息,如标题、日期等。另一方面,自定义属性以键/值对的形式存储自定义信息。以下部分介绍如何添加、访问和修改 PowerPoint 演示文稿的内置和自定义属性。

使用 C++ 访问 PowerPoint 演示文稿中的内置属性

以下是访问 PowerPoint 演示文稿中的内置属性的步骤。

  • 首先,使用Presentation 类加载 PowerPoint 文件 。
  • 使用Presentation->get_DocumentProperties()方法访问属性。
  • 使用IDocumentProperties对象和IDocumentProperties->get_Category()、IDocumentProperties->get_Author()等方法读取各个属性。

以下示例代码显示了如何使用 C++ 访问 PowerPoint 演示文稿中的内置属性。

// File path
const String sourceFilePath = u"SourceDirectory\Slides\SamplePresentation.pptx";// Load the presentation file
auto presentation = System::MakeObject<Presentation>(sourceFilePath);// Get reference of document properties
System::SharedPtr<IDocumentProperties> documentProperties = presentation->get_DocumentProperties();// Print the property values
System::Console::WriteLine(u"Category : {0}", documentProperties->get_Category());
System::Console::WriteLine(u"Current Status : {0}", documentProperties->get_ContentStatus());
System::Console::WriteLine(u"Creation Date : {0}", documentProperties->get_CreatedTime().ToString());
System::Console::WriteLine(u"Author : {0}", documentProperties->get_Author());
System::Console::WriteLine(u"Description : {0}", documentProperties->get_Comments());
System::Console::WriteLine(u"KeyWords : {0}", documentProperties->get_Keywords());
System::Console::WriteLine(u"Last Modified By : {0}", documentProperties->get_LastSavedBy());
System::Console::WriteLine(u"Supervisor : {0}", documentProperties->get_Manager());
System::Console::WriteLine(u"Modified Date : {0}", documentProperties->get_LastSavedTime().ToString());
System::Console::WriteLine(u"Presentation Format : {0}", documentProperties->get_PresentationFormat());
System::Console::WriteLine(u"Last Print Date : {0}", documentProperties->get_LastPrinted().ToString());
System::Console::WriteLine(u"Is Shared between producers : {0}", documentProperties->get_SharedDoc());
System::Console::WriteLine(u"Subject : {0}", documentProperties->get_Subject());
System::Console::WriteLine(u"Title : {0}", documentProperties->get_Title());

使用 C++ 修改 PowerPoint 演示文稿中的内置属性

以下是修改 PowerPoint 演示文稿中的内置属性的步骤。

  • 首先,使用Presentation 类加载 PowerPoint 文件 。
  • 使用Presentation->get_DocumentProperties()方法检索IDocumentProperties对象中的属性。
  • 使用IDocumentProperties对象和IDocumentProperties->set_Author(System::String value)、IDocumentProperties->set_Title(System::String value)等方法修改属性。
  • 最后,使用 Presentation->Save(System::String fname, Export::SaveFormat format) 方法保存演示文稿。

以下示例代码显示了如何使用 C++ 修改内置 PowerPoint 属性。

// File paths
const String sourceFilePath = u"SourceDirectory\Slides\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\ModifyBuiltinProperties_out.pptx";// Load the presentation file
auto presentation = System::MakeObject<Presentation>(sourceFilePath);// Get reference of document properties
System::SharedPtr<IDocumentProperties> documentProperties = presentation->get_DocumentProperties();// Modify the built-in properties
documentProperties->set_Author(u"Aspose.Slides for C++");
documentProperties->set_Title(u"Modifying Presentation Properties");
documentProperties->set_Subject(u"Aspose Subject");
documentProperties->set_Comments(u"Aspose Comments");
documentProperties->set_Manager(u"Aspose Manager");// Save Presentation
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);

使用 C++ 在 PowerPoint 演示文稿中添加自定义属性

以下是在 PowerPoint 演示文稿中添加自定义属性的步骤。

  • 首先,使用Presentation 类加载 PowerPoint 文件 。
  • 使用Presentation->get_DocumentProperties()方法检索IDocumentProperties对象中的属性。
  • 使用IDocumentProperties->idx_set(System::String name, System::SharedPtrSystem::Object value)方法添加自定义属性。
  • 最后,使用 Presentation->Save(System::String fname, Export::SaveFormat format) 方法保存演示文稿。

以下示例代码显示了如何在 PowerPoint 演示文稿中添加自定义属性。

// File paths
const String sourceFilePath = u"SourceDirectory\Slides\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\AddCustomProperties_out.pptx";// Load the presentation file
auto presentation = System::MakeObject<Presentation>(sourceFilePath);// Get reference of document properties
auto documentProperties = presentation->get_DocumentProperties();// Adding Custom properties
documentProperties->idx_set(u"New Custom", ObjectExt::Box<int32_t>(12));
documentProperties->idx_set(u"My Name", ObjectExt::Box<String>(u"Aspose"));
documentProperties->idx_set(u"Custom", ObjectExt::Box<int32_t>(124));// Getting property name at particular index
String getPropertyName = documentProperties->GetCustomPropertyName(2);// Removing selected property
documentProperties->RemoveCustomProperty(getPropertyName);// Save Presentation
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);

在 PowerPoint 演示文稿中访问和修改自定义属性

以下是访问和修改 PowerPoint 演示文稿中的自定义属性的步骤。

  • 首先,使用Presentation 类加载 PowerPoint 文件 。
  • 使用Presentation->get_DocumentProperties()方法检索IDocumentProperties对象中的属性。
  • 循环遍历属性并分别使用IDocumentProperties->GetCustomPropertyName(int32_t index)和IDocumentProperties->idx_get(System::String name)方法访问每个属性的名称和值。
  • 根据要存储的值的类型,使用IDocumentProperties->SetCustomPropertyValue()方法修改所需的自定义属性。
  • 最后,使用 Presentation->Save(System::String fname, Export::SaveFormat format) 方法保存演示文稿。

以下示例代码显示了如何使用 C++ 访问和修改 PowerPoint 演示文稿中的自定义属性。

// File paths
const String sourceFilePath = u"SourceDirectory\Slides\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\AccessAndModifyCustomProperties_out.pptx";// Load the presentation file
auto presentation = System::MakeObject<Presentation>(sourceFilePath);// Create a reference to DocumentProperties object associated with Presentation
System::SharedPtr<IDocumentProperties> documentProperties = presentation->get_DocumentProperties();// Access custom properties
for (int32_t i = 0; i < documentProperties->get_CountOfCustomProperties(); i++)
{
// Print the name and value of custom properties
System::Console::WriteLine(u"Custom Property Name : {0}", documentProperties->GetCustomPropertyName(i));
System::Console::WriteLine(u"Custom Property Value : {0}", documentProperties->idx_get(documentProperties->GetCustomPropertyName(i)));// Modify the custom property
documentProperties->SetCustomPropertyValue(documentProperties->GetCustomPropertyName(i), String::Format(u"Title : {0}", i));
}// Save Presentation
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);

Aspose.Slides使用教程:使用 C++ 访问或修改 PowerPoint 文件的属性相关推荐

  1. Aspose.Slides使用教程:使用 C++ 在 PowerPoint 演示文稿中嵌入视频

    目录 用于在 PowerPoint 演示文稿中嵌入视频的 C++ API 使用 C++ 在 PowerPoint 演示文稿中嵌入视频 在 PowerPoint 演示文稿中嵌入来自 Web 源的视频 使 ...

  2. Aspose.Slides使用教程:使用 C# 在 PowerPoint 演示文稿中添加页眉和页脚

    目录 在 PowerPoint 中管理页眉和页脚的 .NET API 使用 C# 管理讲义和备注幻灯片中的页眉和页脚 更改备注幻灯片的页眉和页脚设置 PowerPoint 演示文稿中的页眉和页脚用于显 ...

  3. Aspose.Slides使用教程:使用 C++ 在 PowerPoint 演示文稿中添加幻灯片切换

    目录 用于在 PowerPoint 演示文稿中添加过渡的 C++ API 使用 C++ 添加幻灯片过渡 使用 C++ 添加高级幻灯片过渡 在 PowerPoint 演示文稿中设置变形过渡类型 在 Mi ...

  4. 删除计算机用户时拒绝访问权限,修改windows文件权限,解决“拒绝访问”或无法删除的问题-win7拒绝访问...

    修改windows文件夹权限 在<<Windows本地服务器搭建,不使用Tomcat的服务器>>一文中,介绍了利用Windows提供的功能,建立一个简单测试的服务器的方法,实现 ...

  5. 更改计算机用户名 拒绝访问,电脑修改Administrator帐户属性提示拒绝访问的解决方法...

    ‍ Administrator是Windows操作系统默认的管理员账户,在操作系统中只有一个管理员账户的情况下,尽量不要轻易停用管理员账户,否则就有可能引起错误.如果电脑中出现了修改不了Adminis ...

  6. 想在Java中把PPT转化为PDF吗?教你用Aspose.Slides轻松搞定!

    PDF已成为最广泛和最常用的数字文档格式.由于PDF格式具有固定的布局,因此大多数文档在共享之前都已转换为PDF. 在将各种文档转换为PDF格式的过程中,PPT到PDF的转换是一种流行的用例,且非常的 ...

  7. Python 代理类实现和控制访问与修改属性的权限

    本篇文章主要内容 代理类主要功能是将一个类实例的属性访问和控制代理到代码内部另外一个实例类,将想对外公布的属性的访问和控制权交给代理类来操作,保留不想对外公布的属性的访问或控制权,比如只读访问,日志功 ...

  8. aspose.slides for java去除水印

    前一段时间使用aspose.slides for java,处理了下才去除的水印,但是时间一久就忘记了,重新整理了下 下载aspose-slides-19.3-jdk16.jar,重命名为aspose ...

  9. PPT处理控件Aspose.Slides功能演示:使用 C# 在 PowerPoint 演示文稿中创建 SmartArt

    演示文稿中的 SmartArt 用于以视觉形式提供信息.有时,选择使简单的文本更具吸引力.而在其他情况下,它用于演示流程图.流程.不同实体之间的关系等.下面将介绍如何使用 C# 以编程方式在 Powe ...

最新文章

  1. 4 app版本号 swift_已开源 app 实现检查更新的简单方式
  2. 按某列获取几行_机器学习获取数据难?别忘记特征工程
  3. H264学习_基本数据结构
  4. python添加环境变量_windows系统下python学习-1 (python环境变量配置)
  5. 使用Microsoft数据迁移助手在Oracle数据库和SQL Server之间迁移的具体示例
  6. [开源]KJFramework.Message 智能二进制消息框架 - 新能力
  7. [JSOI2017]原力(分块+map(hash))
  8. python100例详解-python案例讲解
  9. 麦克马斯特计算机工程专业,麦克马斯特大学计算机专业成功录取
  10. linux pam limits.so,linux – 即使需要pam_limits.so,ulimit也不会读取打开文件描述符limits.conf设置...
  11. filezilla提示 local: unable to open
  12. 普通人想做自媒体赚钱,应该做什么呢?
  13. antd 阿里图标库扩展a-icon 图标
  14. 怪物猎人世界取得服务器信息,怪物猎人世界 Steam好友联机服务器选择工具V1.2...
  15. 币圈炒币只有四种人能赚到钱其中之一是使用炒币机器人的玩家
  16. 安装Docker所遇到的问题
  17. 没有基础可以学java吗?零基础学java
  18. 谈谈ChatGPT 背后的核心技术论文
  19. ajax同步和异步区别
  20. 360杀毒属于计算机操作系统吗,360杀毒软件 统一操作系统UOS,保护您的电脑安全...

热门文章

  1. golang:%v,%+v,%#v的区别
  2. IE6、IE7、IE8之IE多版本共存的几种方法(转)
  3. 从零开始搭二维激光SLAM --- Hector论文公式推导与相关代码解析
  4. JAVA求班级男女生比例_java编程:给你一个班级的名单,随机分成6个组的问题解决办法...
  5. iPad 变身做电脑显示器
  6. 2023全网首发抖音标签检测程序源码+花800买的/最新版本
  7. 文旅夜游——让城市夜晚更加绚烂多彩
  8. 基于51单片机的呼出有毒气体(煤气、酒精、co)检测仪设计
  9. 【蓝桥杯】【Python】次数差
  10. [转载]只需要读内存实现的Dota全图