Change Font Styles in PowerPoint Using Java

import com.spire.presentation.*;
import com.spire.presentation.drawing.FillFormatType;

import java.awt.*;

public class ChangeFontStyles {

public static void main(String[] args) throws Exception {

//Create a Presentation object
Presentation presentation = new Presentation();

//Load the sample PowerPoint file

//Get the text shape
IAutoShape shape = (IAutoShape) presentation.getSlides().get(0).getShapes().get(0);

//Get the first paragraph and change the font color of it
ParagraphEx paragraph = shape.getTextFrame().getParagraphs().get(0);
PortionEx textRange = paragraph.getFirstTextRange();

//Get the second paragraph and make the text bold, italic and unlined
paragraph = shape.getTextFrame().getParagraphs().get(1);
textRange = paragraph.getFirstTextRange();

//Get the third paragraph and change the font name and size
paragraph = shape.getTextFrame().getParagraphs().get(2);
textRange = paragraph.getFirstTextRange();
textRange.getFormat().setLatinFont(new TextFont("Segoe Print"));

//Save the document
presentation.saveToFile("output/ChangeFontStyles.pptx", FileFormat.PPTX_2013);




Sharing Java Code

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

AI learns to fly (Part 1) | Airplane simulation and Reinforcement Learning

What Not To Do In The Tricoach Industry

Improvements In CompletableFuture

Developing Event-Driven Microservices in Java, JavaScript, Python, .NET, and Go

Packaging & Tool Release

$BITA — Pool 0 — UniSwap

[LeetCode]#1260. Shift 2D Grid

A Coders Diary | Introduction

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrew Wilson

Andrew Wilson

Sharing Java Code

More from Medium

Java/ Add Footer to PowerPoint Document

A Java Reverse Engineering Experience

Experience with Spring batch and docker

Build maven project with push to docker hub in same time