Ok, I solved my problem with images, but I still have the other questions ;)

Sent from my iPhone

On 14 avr. 2011, at 00:14, Herve Girod <[email protected]> wrote:

> Hello,
> 
> I'm using the HSLF API for some time now, and it works very well, but I have 
> some questions on some things I can't do. I do'nt know if it's because the 
> API is (still) incomplete on some areas, or just if I'm not using it well. My 
> questions are:
> - Is it possible to embed Fonts in a PowerPoint file by using the API? It's 
> possible to do it by using an existing PowerPoint file master, but I would 
> like to do it when I encounter a Font which does not exist in the 
> FontCollection. For example is it possible to create a new PPFont "from 
> scratch" using an existing TTF file, and add it to the collection?
> - Is it possible to group Shapes? I tried to use ShapeGroups, but the 
> resulting PPT file still did not have groups of Shapes
> 
> And finally, is it possible to add image data to the slides. I tried the 
> following approach, but it did not work (no exception, but no image either):
> 
>     public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, 
> int sx1, int sy1,  int sx2, int sy2, Color color1, ImageObserver observer) {
>         Rectangle rectangle = new Rectangle(sx1, sy1, sx2 - sx1, sy2 - sy1);
>         Shape shape = trans.createTransformedShape(rectangle);
>         Rectangle rec = shape.getBounds();
>         addImage(image, rec);
> 
>         return true;
>     }
> 
>     private void addImage(Image image, Rectangle rec) {
>         SlideShow show = slide.getSlideShow();
>         if (image instanceof RenderedImage) {
>             try {
>                 byte[] b = getImageData((RenderedImage)image);
>                 int idx = show.addPicture(b, Picture.PNG);
>                 Picture pict = new Picture(idx);
>                 pict.setAnchor(rec);
>                 slide.addShape(pict);
>             } catch (IOException e) {
>             }
>         }
>     }
> 
>     private byte[] getImageData(RenderedImage image) throws IOException {
>         ByteArrayOutputStream stream = new ByteArrayOutputStream(100);
>         ImageIO.write(image, "png", stream);
>         stream.close();
>         
>         return stream.toByteArray();
>     }
> 
> 
> FYI, I have developed a Graphics2D drop-in which draw in a PPT context a 
> Swing hierarchy, and apart from these problems and other small bugs, it works 
> well. The project is here: https://sourceforge.net/projects/j661/
> 
> Thanks!!
> 
> Herve Girod

Reply via email to