Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 10, 2021 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/c5d443992489bba0bbd7256a8fb2d2e0 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/c5d443992489bba0bbd7256a8fb2d2e0 to your computer and use it in GitHub Desktop.
Add, Access, or Modify PowerPoint Presentation using C#
// 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);
// 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)]);
}
// 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);
// 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);
// 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