Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Poi Creating Auto Shape in PowerPoint Using Java

Related Tutorials


 
 

Share on Google+Share on Google+

Creating Auto Shape in PowerPoint Using Java

Advertisement
In this example we are going to create auto shape on PowerPoint slide using java.

Creating Auto Shape in PowerPoint Using Java

     


In this example we are going to create auto shape on PowerPoint slide using java.

In this example, we are creating the object of AutoShape .We are passing the shape type into AutoShape as argument parameter .We are passing ShapeTypes.Star32 as shape type. Then we are using setAnchor() method to give the position of the shape. To fill the color we are using setFillColr(Color colr)  method.
  
 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.model.*;
import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.hslf.usermodel.*;
import java.io.*;
import java.awt.*;
import org.apache.poi.hslf.model.TextBox;
class autoShape
{
  public static void main(String a[])
  {
  try
  SlideShow slideShow = new SlideShow();
 Slide slide = slideShow.createSlide();
 AutoShape sh1 = new AutoShape(ShapeTypes.Star32);
 sh1.setAnchor(new java.awt.Rectangle
(
00600600));
 sh1.setFillColor(Color.red);
 AutoShape sh2 = new AutoShape(ShapeTypes.Star32);
 sh2.setAnchor(new java.awt.Rectangle
(
200200200200));
 sh2.setFillColor(Color.green);
  AutoShape sh3 = new AutoShape(ShapeTypes.Star32);
 sh3.setAnchor(new java.awt.Rectangle
(
150150300300));
 sh3.setFillColor(Color.red);
  AutoShape sh4 = new AutoShape(ShapeTypes.Star32);
 sh4.setAnchor(new java.awt.Rectangle
(
100100400400));
 sh4.setFillColor(Color.green);
 slide.addShape(sh1);
 slide.addShape(sh4);
     slide.addShape(sh3);
     slide.addShape(sh2);
  FileOutputStream out = new FileOutputStream
(
"autoShape.ppt");
  slideShow.write(out);
  out.close();
  }catch(Exception e){}
  }}

The output of the program is given below:

Download this example.

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



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

Related Tutorials

Discuss: Creating Auto Shape in PowerPoint Using Java   View All Comments

Post your Comment


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