Learn how to add, access, and modify document properties in PowerPoint presentations using Java: https://blog.aspose.com/2021/08/12/access-modify-properties-of-powerpoint-files-using-java/
Last active
September 14, 2021 16:05
-
-
Save aspose-com-gists/399dd464fe55eed7d9c9a2f088292039 to your computer and use it in GitHub Desktop.
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("Presentation.pptx"); | |
try { | |
// Create a reference to IDocumentProperties object associated with presentation | |
IDocumentProperties dp = pres.getDocumentProperties(); | |
// Display the built-in properties | |
System.out.println("Category : " + dp.getCategory()); | |
System.out.println("Current Status : " + dp.getContentStatus()); | |
System.out.println("Creation Date : " + dp.getCreatedTime()); | |
System.out.println("Author : " + dp.getAuthor()); | |
System.out.println("Description : " + dp.getComments()); | |
System.out.println("KeyWords : " + dp.getKeywords()); | |
System.out.println("Last Modified By : " + dp.getLastSavedBy()); | |
System.out.println("Supervisor : " + dp.getManager()); | |
System.out.println("Modified Date : " + dp.getLastSavedTime()); | |
System.out.println("Presentation Format : " + dp.getPresentationFormat()); | |
System.out.println("Last Print Date : " + dp.getLastPrinted()); | |
System.out.println("Is Shared between producers : " + dp.getSharedDoc()); | |
System.out.println("Subject : " + dp.getSubject()); | |
System.out.println("Title : " + dp.getTitle()); | |
} finally { | |
if (pres != null) pres.dispose(); | |
} |
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("Presentation.pptx"); | |
try { | |
// Create a reference to DocumentProperties object associated with presentation | |
IDocumentProperties dp = pres.getDocumentProperties(); | |
// Access and modify custom properties | |
for (int i = 0; i < dp.getCountOfCustomProperties(); i++) { | |
// Display names and values of custom properties | |
System.out.println("Custom Property Name : " + dp.getCustomPropertyName(i)); | |
System.out.println("Custom Property Value : " + dp.get_Item(dp.getCustomPropertyName(i))); | |
} | |
// Save your presentation to a file | |
pres.save("CustomDemoModified.pptx", SaveFormat.Pptx); | |
} finally { | |
if (pres != null) pres.dispose(); | |
} |
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("Presentation.pptx"); | |
try { | |
// Get Document Properties | |
IDocumentProperties dProps = pres.getDocumentProperties(); | |
// Add Custom properties | |
dProps.set_Item("New Custom", 12); | |
dProps.set_Item("My Name", "Mudassir"); | |
dProps.set_Item("Custom", 124); | |
// Get property name at particular index | |
String getPropertyName = dProps.getCustomPropertyName(2); | |
// To remove selected property | |
//dProps.removeCustomProperty(getPropertyName); | |
// Save presentation | |
pres.save("CustomDemo.pptx", SaveFormat.Pptx); | |
} finally { | |
if (pres != null) pres.dispose(); | |
} |
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("Presentation.pptx"); | |
try { | |
// Create a reference to IDocumentProperties object associated with Presentation | |
IDocumentProperties dp = pres.getDocumentProperties(); | |
// Set the built-in properties | |
dp.setAuthor("Aspose.Slides for Java"); | |
dp.setTitle("Modifying Presentation Properties"); | |
dp.setSubject("Aspose Subject"); | |
dp.setComments("Aspose Description"); | |
dp.setManager("Aspose Manager"); | |
// Save your presentation to a file | |
pres.save("DocProps.pptx", SaveFormat.Pptx); | |
} finally { | |
if (pres != null) pres.dispose(); | |
} |
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("Presentation.pptx"); | |
try { | |
// Create a reference to DocumentProperties object associated with presentation | |
IDocumentProperties dp = pres.getDocumentProperties(); | |
// Access and modify custom properties | |
for (int i = 0; i < dp.getCountOfCustomProperties(); i++) { | |
// Modify values of custom properties | |
dp.set_Item(dp.getCustomPropertyName(i), "New Value " + (i + 1)); | |
} | |
// Save your presentation to a file | |
pres.save("CustomDemoModified.pptx", SaveFormat.Pptx); | |
} finally { | |
if (pres != null) pres.dispose(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment