Apache POI PPT Formatting Text in Apache POI PPT

How to format text in Apache POI PPT?

Text in a presentation can be formatted by using the methods of XSLFTextRun class. To do this, create an XSLFTextRun class object by selecting one of the slide layouts as follows:

Font size of the text can be set in the presentation using setFontSize().

Below code snippet will show how to apply different formatting styles (bold, italic, underline, strikeout) to the text.

To get line breaks between paragraphs, use addLineBreak() of the XSLFTextParagraph class as shown below:

Below is the complete program to format the text using all the above methods:

Save the above code as TextFormating.java and then compile and execute it from the command prompt as shown below:

It will compile and execute to generate below output:

Slide with formatted text will appear as shown below:


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Apache POI PPT Topics