Home Java Poi Set Textbox in PowerPoint Slide Using Java



Set Textbox in PowerPoint Slide Using Java
Posted on: March 14, 2008 at 12:00 AM
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.

Related Tags for Set Textbox in PowerPoint Slide Using Java:
javacstringidetexttextboxobjectiomakesizemethodvalueanchorpowerpointusingintthisidsetpositioncreateshowtexpoiexamplefinaladdboxtopointexampowerfinallyposerpastshexteslideshapeitlastdescanliusepefirstinshapassasmnttrososicaddosiosjadafteresxboxallmehowintoobjcreatingxawerxampseeatkisirhallmplgoeaandarstrslixtvattzssriringtbothshoavstatiapaluafhateslfinesljepleplndono


More Tutorials from this section

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

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.