C++를 사용하여 PowerPoint 파일의 속성 액세스 또는 수정

PowerPoint 파일에는 프레젠테이션에 대한 추가 정보를 제공하는 메타데이터 또는 문서 속성이 포함되어 있습니다. 여기에는 프레젠테이션의 제목, 날짜, 저자 등과 같은 정보가 포함됩니다. 이 기사에서는 C++를 사용하여 PowerPoint 프레젠테이션의 속성에 액세스하고 속성을 수정하는 방법을 배웁니다.

PowerPoint 프레젠테이션의 속성 액세스 및 수정을 위한 C++ API

Aspose.Slides for C++은 PowerPoint 파일 작업을 위한 C++ API입니다. 추가 소프트웨어 없이 PowerPoint 파일을 만들고 읽고 업데이트할 수 있습니다. 또한 API를 사용하여 PowerPoint 프레젠테이션의 속성에 액세스하고 수정할 수 있습니다. NuGet을 통해 API를 설치하거나 다운로드 섹션에서 직접 다운로드할 수 있습니다.

PM> Install-Package Aspose.Slides.Cpp

PowerPoint 프레젠테이션의 속성 유형

PowerPoint 프레젠테이션에는 기본 제공 속성과 사용자 지정 속성이라는 두 가지 유형의 속성이 있습니다. 기본 제공 속성은 제목, 날짜 등과 같은 프레젠테이션에 대한 일반 정보를 저장합니다. 반면에 사용자 지정 속성은 키/값 쌍에 사용자 지정 정보를 저장합니다. 다음 섹션에서는 PowerPoint 프레젠테이션의 기본 제공 및 사용자 지정 속성을 추가, 액세스 및 수정하는 방법을 다룹니다.

C++를 사용하여 PowerPoint 프레젠테이션의 기본 제공 속성에 액세스

다음은 PowerPoint 프레젠테이션의 기본 제공 속성에 액세스하는 단계입니다.

다음 샘플 코드는 C++를 사용하여 PowerPoint 프레젠테이션의 기본 제공 속성에 액세스하는 방법을 보여줍니다.

// 파일 경로
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";

// 프레젠테이션 파일 로드
auto presentation = System::MakeObject<Presentation>(sourceFilePath);

// 문서 속성 참조 가져오기
System::SharedPtr<IDocumentProperties> documentProperties = presentation->get_DocumentProperties();

// 속성 값 인쇄
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 프레젠테이션에서 기본 제공 속성을 수정하는 단계입니다.

다음 샘플 코드는 C++를 사용하여 기본 제공 PowerPoint 속성을 수정하는 방법을 보여줍니다.

// 파일 경로
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\ModifyBuiltinProperties_out.pptx";

// 프레젠테이션 파일 로드
auto presentation = System::MakeObject<Presentation>(sourceFilePath);

// 문서 속성 참조 가져오기
System::SharedPtr<IDocumentProperties> documentProperties = presentation->get_DocumentProperties();

// 기본 제공 속성 수정
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");

// 프레젠테이션 저장
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);

C++를 사용하여 PowerPoint 프레젠테이션에 사용자 지정 속성 추가

다음은 PowerPoint 프레젠테이션에 사용자 지정 속성을 추가하는 단계입니다.

다음 샘플 코드는 PowerPoint 프레젠테이션에서 사용자 지정 속성을 추가하는 방법을 보여줍니다.

// 파일 경로
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\AddCustomProperties_out.pptx";

// 프레젠테이션 파일 로드
auto presentation = System::MakeObject<Presentation>(sourceFilePath);

// 문서 속성 참조 가져오기
auto documentProperties = presentation->get_DocumentProperties();

// 사용자 정의 속성 추가
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));

// 특정 인덱스에서 속성 이름 가져오기
String getPropertyName = documentProperties->GetCustomPropertyName(2);

// 선택한 속성 제거
documentProperties->RemoveCustomProperty(getPropertyName);

// 프레젠테이션 저장
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);

PowerPoint 프레젠테이션에서 사용자 지정 속성 액세스 및 수정

다음은 PowerPoint 프레젠테이션에서 사용자 지정 속성에 액세스하고 수정하는 단계입니다.

다음 샘플 코드는 C++를 사용하여 PowerPoint 프레젠테이션의 사용자 지정 속성에 액세스하고 수정하는 방법을 보여줍니다.

// 파일 경로
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\AccessAndModifyCustomProperties_out.pptx";

// 프레젠테이션 파일 로드
auto presentation = System::MakeObject<Presentation>(sourceFilePath);

// Presentation과 연결된 DocumentProperties 개체에 대한 참조 만들기
System::SharedPtr<IDocumentProperties> documentProperties = presentation->get_DocumentProperties();

// 사용자 정의 속성에 액세스
for (int32_t i = 0; i < documentProperties->get_CountOfCustomProperties(); i++)
{
	// 사용자 정의 속성의 이름과 값 인쇄
	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)));

	// 사용자 정의 속성 수정
	documentProperties->SetCustomPropertyValue(documentProperties->GetCustomPropertyName(i), String::Format(u"Title : {0}", i));
}

// 프레젠테이션 저장
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);

무료 라이선스 받기

평가 제한 없이 API를 사용해 보려면 무료 임시 라이선스를 요청할 수 있습니다.

결론

이 문서에서는 PowerPoint 프레젠테이션의 기본 제공 속성에 액세스하고 수정하는 방법을 배웠습니다. 또한 Aspose.Slides for C++ API를 사용하여 사용자 지정 PowerPoint 속성을 추가, 액세스 및 수정하는 방법을 살펴보았습니다. PowerPoint 관련 작업을 자동화하기 위한 많은 추가 기능이 있는 강력한 API입니다. API에 대한 자세한 내용은 공식 문서에서 확인할 수 있습니다. 문의 사항이 있는 경우 무료 지원 포럼에 문의해 주십시오.

또한보십시오