Skip to Content

Recently i came across one api with which we can read and write a ppt file.Documentation

To start with the development we will add the api to the class path of the webdynpro project.

image

We will first create a view in our WebDynpro project and add one text area and one button to it.

On Action of button click we will read data from the text area and write it to the ppt file.

image

onAction of Button

try {

//Instantiate a Presentation object that represents a PPT file

Presentation pres=new Presentation();

//Adding an empty slide to the presentation and getting the reference of that empty slide Slide slide=pres.addEmptySlide();

//Adding a rectangle (X=2400, Y=1800, Width=1000 & Height=500) to the slide

com.aspose.slides.Rectangle rect=slide.getShapes().addRectangle(2400,1800,1000,500);

//Hiding the lines of rectangle

rect.getLineFormat().setShowLines(false);

//Adding a text frame to the rectangle with the text given in the text area rect.addTextFrame(wdContext.currentContextElement().getText());

//Removing the first slide of the presentation which is always added by //Aspose.Slides by default while creating the presentation

pres.getSlides().removeAt(0);

//Creating a file output stream to write the output file

FileOutputStream fostream=new FileOutputStream(“C:\\test.ppt”);

wdComponentAPI.getMessageManager().reportSuccess(“File created”);

//Writing the presentation as a PPT file

pres.write(fostream);

//Closing the streams

fostream.close();

catch(Exception ex) {

 wdComponentAPI.getMessageManager().reportException(ex.toString(),false);

 }

It will create a PPT file on the server on the path specified.

image

API can be downloaded from the following location Download API

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Kapil Kamble
    Hi thr…

    very informative blog…I had a doubt…I hope we can programmaticaly/dynamically design the PPT as well 🙂 Can we ?

    Regards
    Kapil

    (0) 

Leave a Reply