Learn how to access, add, and modify document properties in PowerPoint presentations using C#: https://blog.aspose.com/2021/09/10/manipulate-properties-in-powerpoint-files-using-csharp/
Last active
September 10, 2021 14:54
-
-
Save aspose-com-gists/c5d443992489bba0bbd7256a8fb2d2e0 to your computer and use it in GitHub Desktop.
Add, Access, or Modify PowerPoint Presentation using C#
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
// Load presentation | |
Presentation pres = new Presentation("AccessBuiltin Properties.pptx"); | |
// Create a reference to IDocumentProperties object associated with Presentation | |
IDocumentProperties documentProperties = pres.DocumentProperties; | |
// Display the builtin properties | |
System.Console.WriteLine("Category : " + documentProperties.Category); | |
System.Console.WriteLine("Current Status : " + documentProperties.ContentStatus); | |
System.Console.WriteLine("Creation Date : " + documentProperties.CreatedTime); | |
System.Console.WriteLine("Author : " + documentProperties.Author); | |
System.Console.WriteLine("Description : " + documentProperties.Comments); | |
System.Console.WriteLine("KeyWords : " + documentProperties.Keywords); | |
System.Console.WriteLine("Last Modified By : " + documentProperties.LastSavedBy); | |
System.Console.WriteLine("Supervisor : " + documentProperties.Manager); | |
System.Console.WriteLine("Modified Date : " + documentProperties.LastSavedTime); | |
System.Console.WriteLine("Presentation Format : " + documentProperties.PresentationFormat); | |
System.Console.WriteLine("Last Print Date : " + documentProperties.LastPrinted); | |
System.Console.WriteLine("Is Shared between producers : " + documentProperties.SharedDoc); | |
System.Console.WriteLine("Subject : " + documentProperties.Subject); | |
System.Console.WriteLine("Title : " + documentProperties.Title); |
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
// Load presentation | |
Presentation presentation = new Presentation("Presentation.pptx"); | |
// Get reference of document properties | |
IDocumentProperties documentProperties = presentation.DocumentProperties; | |
// Access custom properties | |
for (int i = 0; i < documentProperties.CountOfCustomProperties; i++) | |
{ | |
// Display names and values of custom properties | |
System.Console.WriteLine("Custom Property Name : " + documentProperties.GetCustomPropertyName(i)); | |
System.Console.WriteLine("Custom Property Value : " + documentProperties[documentProperties.GetCustomPropertyName(i)]); | |
} |
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
// Load presentation | |
Presentation presentation = new Presentation("Presentation.pptx"); | |
// Get reference of document properties | |
IDocumentProperties documentProperties = presentation.DocumentProperties; | |
// Add custom properties | |
documentProperties["New Custom"] = 12; | |
documentProperties["My Name"] = "Mudassir"; | |
documentProperties["Custom"] = 124; | |
// Save presentation | |
presentation.Save("CustomDocumentProperties_out.pptx", SaveFormat.Pptx); |
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
// Load presentation | |
Presentation presentation = new Presentation("ModifyBuiltinProperties.pptx"); | |
// Create a reference to IDocumentProperties object associated with Presentation | |
IDocumentProperties documentProperties = presentation.DocumentProperties; | |
// Set the builtin properties | |
documentProperties.Author = "Aspose.Slides for .NET"; | |
documentProperties.Title = "Modifying Presentation Properties"; | |
documentProperties.Subject = "Aspose Subject"; | |
documentProperties.Comments = "Aspose Description"; | |
documentProperties.Manager = "Aspose Manager"; | |
// Save your presentation to a file | |
presentation.Save("DocumentProperties_out.pptx", SaveFormat.Pptx); |
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
// Load presentation | |
Presentation presentation = new Presentation("Presentation.pptx"); | |
// Get reference of document properties | |
IDocumentProperties documentProperties = presentation.DocumentProperties; | |
// Access and modify custom properties | |
for (int i = 0; i < documentProperties.CountOfCustomProperties; i++) | |
{ | |
// Modify values of custom properties | |
documentProperties[documentProperties.GetCustomPropertyName(i)] = "New Value " + (i + 1); | |
} | |
// Save presentation | |
presentation.Save("CustomDocumentProperties_out.pptx", SaveFormat.Pptx); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment