Get PowerPoint themes and Color information

Get PowerPoint themes, font details using Java Cloud SDK

In order to make the PowerPoint presentation more appealing and awe striking, we implement various fonts and color palettes. Also, in order to show a consistent layout and to lave a profound amazement experience for end users, we apply PowerPoint themes. However, we may have received a presentation file from different source and would be interested to read PPT theme details as well as find color palette, so that this information can be further utilized. So in this article, we are going to discuss the details on how to programmatically read Microsoft PowerPoint themes information.

PowerPoint Color Scheme Processing API

In order to create, read, edit and convert PowerPoint to variety of supported formats, Aspose.Slides Cloud is a reliable solution. Its REST based architecture enables you to call the API on any platform. Now in order to get all these features in Java application, we have specifically created Aspose.Slides Cloud SDK for Java which is a wrapper around Cloud API. Now in order to use the SDK in Java application, the first step is to add its reference in project by including following information in pom.xml of maven build type project.

<repositories> 
    <repository>
        <id>aspose-cloud</id>
        <name>artifact.aspose-cloud-releases</name>
        <url>http://artifact.aspose.cloud/repo</url>
    </repository>   
</repositories>

<dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-slides-cloud</artifactId>
        <version>22.9.0</version>
    </dependency>
</dependencies>

If you have not created an account yet, you can sign up for a Free Trial over Aspose Cloud using valid email address. Now login using newly created account and lookup/create Client ID and Client Secret at Cloud Dashboard. These details are required for authentication purposes in the following sections.

Get PowerPoint Themes information

As discussed above, we use presentation templates so that we have consistent theme/layout through out the PowerPoint presentation. However, we may have a requirement to get PowerPoint themes details for further processing. Furthermore, the main properties of presentation design elements are determined by a presentation theme. Each theme uses its own unique set of colors, fonts and effects to create the overall look of your slides. The following details allow you to read information about slides themes from a PowerPoint presentation using Java code snippet.

  • First of all, create an object of SlidesApi object while providing ClientID and Client secret as arguments
  • Secondly, create an instance of File which takes address of input PowerPoint template file as parameter
  • Thirdly, read the content of PowerPoint files using readAllBytes(…) and save it in byte[] array
  • Now upload the input PowerPoint to Cloud storage using uploadFile(…) method
  • Finally call the getTheme(…) method while providing name of input PowerPoint PowerPoint, slide index. The information is displayed in console.

Read PowerPoint Color Scheme in Java

The PowerPoint processing API also enables us to read powerPoint color scheme details using Java code snippet. The API expects the source file to be available in Cloud storage.

  • First of all, create an object of SlidesApi object while providing ClientID and Client secret as arguments
  • Secondly, call the method getColorScheme(…) which requires PowerPoint from cloud storage and slide index as arguments
  • Now print the color scheme information in console by calling getHyperlink(…) method

The sample presentation template used in above example can be downloaded from RainbowPresentation.potx.

Get PowerPoint Fonts using Java

In this section, we are going to discuss the steps to read PowerPoint fonts information. So we can individually traverse between PowerPoint slides and retrieve fonts information

  • The first step is to create instance of SlidesApi object
  • Secondly, create an object of FontScheme which will hold return data from getFontScheme(…) method
  • Now in order to retrieve font information, please call getName(…) method and print information in console

Read PowerPoint Fonts using cURL Commands

Now its time to read the font scheme details using cURL Commands. However as a pre-requisite, we need to first generate a JWT access token (based on client credentials) while executing the following command.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Now that we have the JWT token, please execute the following command.

curl -v -X GET "https://api.aspose.cloud/v3.0/slides/source.potx/slides/2/theme/fontScheme" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"

Given below is the response body content once the command is executed

{
  "major": {
    "complexScript": "Arial",
    "eastAsian": "Segoe Print",
    "latin": "Segoe Print"
  },
  "minor": {
    "complexScript": "Arial",
    "eastAsian": "Segoe Print",
    "latin": "Segoe Print"
  },
  "name": "Segoe Print",
  "selfUri": {
    "href": "https://api.aspose.cloud/v3.0/slides/source.potx/slides/2/theme/fontScheme",
    "relation": "self",
    "slideIndex": 2
  }
}

Conclusion

We just have learned the steps on how to This article has explained the details on how to get PowerPoint themes information, how to read PowerPoint Color scheme information as well as how to retrieve PowerPoint fonts details. Apart from Java code snippet, you may also retreieve these detils uisng cURL commands. Please note that all our Cloud SDKs are published under MIT license, so you may consider downloading the complete source code from GitHub and modify it as per your requirements. In case of any issues, you may consider approaching us for a quick resolution via free product support forum.

Please visit the following links to learn more about: