I’m in the process of testing your software for use in an application
that requires the decomposition and reassembly of PPT files. I’m
running the Aspose.PowerPoint API for java on an Apple Mac OS X 10.4.3
and using J2SE 1.5.0.
Regarding pictures, I have run into 3 (maybe 4) different problems. The
attached tar file contains the java test code I’m running along with
two test .ppt files, resulting printouts, and images written to file.
In test 1:
The input is Test1.ppt, which contains two slides, the first with three
images, the second with four images. Iterating over the shapes within
each slide, I print out the picture id of the shape.
Then I get the list of pictures (Pictures pictures =
pres.getPictures();). For each picture on the list, I check the
ImageFormat and write the image to a file.
Problem 1: Four of the .png files written are unreadable by two
different image tools (Preview and Graphic Converter). The message from
Graphic Converter is:
The file “img_4.png” is broken, the format is unknown or it isn’t a graphics file.
A dump of the first few bytes of the file header are as follows (perhaps this is another Endian problem?):
A3 54 D7 D4 D4 7F FC 6C C5 81 FC 58 03 F7 0B FF
89 50 4E 47 0D 0A 1A 0A 00 00 00 00 49 48 44 52
(Possible) Problem 2: All of the images had imageFormats = 6 (png).
I don’t have the sources for these images, but I suspect that not
all of them were originally .png files. However, I have done another test where I
created a new presentation with a single slide, inserted a .jpg file, and run my test code. In
this case, the image was correctly given an imageFormat == jpg. There may be nothing
wrong with your software, but I include this in case it helps with understanding Problem 1.
In test 2:
The input is Test2.ppt, which contains a single slide with 6 pictures.
When I check the slide and iterate over the shapes within the slide, I
find 6 picture frames and can print out the picture ids (1,3,4,5,6,7).
I then get the list of pictures from the presentation (Pictures
pictures = pres.getPictures();). The pictures.size() equals 1 and the
single image written to file is an uncropped version of one of the
images visible in the slide. If I try (Picture pict =
picts.getPictureById(1)) in this case, I get a NullPointerException
(not included in the java test code attached).
Problem 2: How do I access the other pictures?
Thanks in advance,