You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by sailaja Nagarabettu <na...@gmail.com> on 2014/09/10 18:38:49 UTC

Issue regarding PPT

Hi All,

I have a few requirements related to powerpoint , PFB the reqs

1) clone a slide from existing one to new ppt.
2) Read all the text inside the slide (header,footer,body,tables....).
3)Replace the text with some other value eg: if the slide has a text as
{title}  need to read this text & replace title with "test" and update the
slide.
4)Do other operations like replace picture,change background color...


Please let me how i can use POI for this.

For 1st req i could find only sol as removing other slides which r not req.
For 2nd i tried using Textruns() but this is not reading the text inside
the tables or body of the slide.

Please provide ur valuable suggestions for this ASAP.

Re: Issue regarding PPT

Posted by Tonni Tielens <to...@gmail.com>.
Hi Sailaja,

Regarding 2). I'm doing the same indeed by scanning all text runs in all
text paragraphs. For tables, you indeed need to walk through all tables and
their cells, I guess.

Regarding 3). I'm doing something similar. But note that Powerpoint might
store a text in a text paragraph in several textruns. E.g. the text "Hello
world!" in one text paragraph, might be stored one, two, three or even more
textruns. You can simply call .setText on a text paragraph, but this will
clear all textruns and might mess up your text layout. The workaround I
created for this is to only call setText on the first textrun in the first
text paragraph with the appropriate text and call setText("") on all other
textruns in that text paragraph. An example can be found on
http://pastebin.com/Y7vFUcEN. It's Scala code, but you should be able to
map it to Java code.

Regarding 4). I'm not sure how to replace pictures, but you can simply
create new ones based on existing images on disk. See:
http://poi.apache.org/slideshow/xslf-cookbook.html#AddImage

2014-09-10 18:38 GMT+02:00 sailaja Nagarabettu <na...@gmail.com>:

> Hi All,
>
> I have a few requirements related to powerpoint , PFB the reqs
>
> 1) clone a slide from existing one to new ppt.
> 2) Read all the text inside the slide (header,footer,body,tables....).
> 3)Replace the text with some other value eg: if the slide has a text as
> {title}  need to read this text & replace title with "test" and update the
> slide.
> 4)Do other operations like replace picture,change background color...
>
>
> Please let me how i can use POI for this.
>
> For 1st req i could find only sol as removing other slides which r not req.
> For 2nd i tried using Textruns() but this is not reading the text inside
> the tables or body of the slide.
>
> Please provide ur valuable suggestions for this ASAP.
>