Page 1 of 1

adding a Image

PostPosted: Tue May 15, 2012 10:46 am
by oscar.novillo
Hello,

could anyone post a complete code example of how to add a image to a pptx?

thanks in advance

Re: adding a Image

PostPosted: Fri May 18, 2012 3:33 pm
by jason

Re: adding a Image

PostPosted: Mon May 28, 2012 11:41 am
by oscar.novillo
yes, it works, many thanks

Re: adding a Image

PostPosted: Tue Jun 12, 2012 10:54 pm
by sebastian
This example uses a file.
I wonder if it is possible to add a picture using a BufferedImage created during runtime.
Any informations on this?

Re: adding a Image

PostPosted: Tue Jun 12, 2012 11:14 pm
by jason
You can use instead the method:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
public static BinaryPartAbstractImage createImagePart(
                        OpcPackage opcPackage,
                        Part sourcePart, byte[] bytes) throws Exception
 
Parsed in 0.014 seconds, using GeSHi 1.0.8.4


but note that behind the scenes, it still creates a temp file. This is because org.apache.xmlgraphics.image.loader.ImageManager gets org.apache.xmlgraphics.image.loader.ImageInfo from a URL.

Hmmm... I wonder whether it could be fed a data URI?

Re: adding a Image

PostPosted: Wed Jun 13, 2012 4:20 pm
by sebastian
Thanks for your answer.
It worked for me. I used a PngEncoder to encode the BufferedImage and then put it in as a byte array.

A temp file creation is ok, because we have access to the filesystem but the images are not saved but need to be generated with real time data for each new presentation. That was the whole problem.

Thanks for your help.