Working on Rich Text Format on Slide Using Java
In this example we are going to create a slide then we will learn how we can work on rich text using java.
In this example we are creating an object of SlideShow after that we are using createSlide() method to create an object of Slide. To make a textbox we need first create an object of TextBox .Then by use of setText(String str) we can pass the string value in textbox.To get blocks of text we need getTextRuns()
The getTextAsString() and getTextAsVector() are two method which is used to get the text back. The getTextAsString() returns a single string with all the text in it and getTextAsVector() returns a vector of strings, one for each text record found in the file.
Changing Tex. We can change the text via TextRun.setText(String) or RichTextRun.setText(String). But it is not yet possible to add additional TextRuns or RichTextRuns.
Methods used in this example::
setText(java.lang.String text):
This method is used to change the text or to set the text.
setBold(boolean bold):
This method is used set text is bold or not.
setItalic(boolean italic):
This method is used to set italic type .
setUnderlined(boolean underlined):
This method is used to set underline.
setFontSize(int fontSize):
This method is used to set the font size.
setFontColor(int bgr):
This method is used to set the background color of the text.
setFontColor(java.awt.Color color):
This method is used to set the color of the text, as a java.awt.Color
setAlignment(int align):
This method is used to set the type of horizontal alignment for the text.
The code of the program is given below:
import org.apache.poi.hslf.HSLFSlideShow;
|
The output of the program is given below: