I extended HSLF to support custom image renderers. Here is what you need to do 
to render WMF:

1. Checkout the latest trunk.
2. Download Apache Batik, http://xmlgraphics.apache.org/batik/
3. Include the Batik jar in the classpath.
4. Below is a mock up a class that can render WMF using Batik. Include it in 
your project.

package org.apache.poi.hslf.blip;
import org.apache.poi.hslf.usermodel.PictureData;
import org.apache.poi.hslf.model.Picture;

import java.awt.*;
import java.io.*;

/**
 * Use Apache Batik to render WMF into Graphics2D
 *
 * @author Yegor Kozlov
 */
public class WMFImagePainter  implements ImagePainter {
    public void paint(Graphics2D graphics, PictureData pict, Picture parent) {

        DataInputStream is = new DataInputStream(new 
ByteArrayInputStream(pict.getData()));
        org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore wmfStore =
                new org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore();
        try {
            wmfStore.read(is);
        } catch (IOException e){
            e.printStackTrace();
            return;
        }

        Rectangle anchor = parent.getAnchor();
        float scale = (float)anchor.width/wmfStore.getWidthPixels();

        org.apache.batik.transcoder.wmf.tosvg.WMFPainter painter =
                new org.apache.batik.transcoder.wmf.tosvg.WMFPainter(wmfStore, 
0, 0, scale);
        graphics.translate(anchor.x, anchor.y);
        painter.paint(graphics);
    }
}

I didn't research it deeply. Try to play with the Batik classes.

5. Add the following line before rendering:
PictureData.setImagePainter(Picture.WMF, new WMFImagePainter ());

6. Subsequent calls of Slide.draw(Graphics gr) will use WMFImagePainter for WMF 
images and
you should see WMF in the generated images. Let me know about your results.

Regards,
Yegor

Thank you, I greatly appreciate all of your time and help.

Travis

Yegor Kozlov wrote:
That sounds quite interesting, actually. Where do I start? I've checked
out the various .draw() methods. I am not sure what shape.draw() is doing though, it appears to just be calling the log() method in POILogger.

OK. I will find time this weekend to review the code and prepare a
"how to" for you.

Yegor

Travis

Yegor Kozlov wrote:
In ppt slides equations are embedded OLE objects. Each OLE object
consists of two parts:
 - snapshot in WMF format. This is what needs to be rendered.
 - the actual binary OLE data. This part is activated by double-click.

Since rendering of WMF is not supported by JDK, the equations don't
appear in the created images.

In next versions of HSLF I plan to use Batik http://xmlgraphics.apache.org/batik/ which
includes a WMF transcoder:
http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/transcoder/wmf/tosvg/WMFPainter.html
If you feel like researching this subject, I can explain how to
extend HSLF code to use third-party image renderers.

Yegor

Is there a similar situation with equations made using the equation editor? I have a presentation where many of the slides have equation object in them that do not appear in the images created from slide.draw().
Thanks,
Travis
Yegor Kozlov wrote:
This kind of background is not yet supported. In particular, HSLF
does not support gradient fills and texture fills. I will see if I can
include this support in poi-3.1-final.

Yegor

I am having an issue with the powerpoint at http://cs.unm.edu/~massless/test3.ppt . When I dump all the slides to image files (png or jpg) there is no background for any of the slides except the first and last. Is there something extra I need to do to get
slide.draw() to render these slides?
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to