Set Textbox in PowerPoint Slide
Using Java

In this example we are going create textbox to set text in PowerPoint using
java.
In this example we are creating an object of ShlideShow, after that
we are using createSlide() method to create an object of
Slide. To make a textbox we need first create an object of TexBox . Then by
use of setText(String str) we can pass the string value in
textbox. At last set the position and textbox size by use of setAnchor()
method. Finally add it into slide by use of addShape(TexBox texbox).
The code of the program is given below:
import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.usermodel.SlideShow;
import java.io.*;
import java.awt.*;
import org.apache.poi.hslf.model.TextBox;
class createTextBox
{
public static void main(String a[])
{
try
{ SlideShow slideShow = new SlideShow();
Slide slide = slideShow.createSlide();
TextBox txtBox = new TextBox();
txtBox.setText("Hello, World!");
txtBox.setAnchor(new java.awt.Rectangle
(300, 100, 300, 50));
slide.addShape(txtBox);
FileOutputStream out = new FileOutputStream
("textBox.ppt");
slideShow.write(out);
out.close();
}catch(Exception e){}
}}
|
The output of the program is given below:

Download this example.

|
Current Comments
0 comments so far (post your own) View All Comments Latest 10 Comments: