Home Java Poi Set Textbox in PowerPoint Slide Using Java
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Set Textbox in PowerPoint Slide Using Java

Advertisement
In this example we are going create textbox to set text in PowerPoint using java.

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
(
30010030050));
 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.

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 14, 2008

Ask Questions?    Discuss: Set Textbox in PowerPoint Slide Using Java  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com