[cairo] Trying to export an EMF file.

Adrian Johnson ajohnson at redneon.com
Wed Jun 9 02:52:29 PDT 2010


On 09/06/10 04:24, Bryan Montgomery wrote:
> Hello,
> I've been trying to find a process today to generate an image to EMF
> (Windows Enhanced MetaFile). I'm able to use the Java HEP package to
> create an EMF - however that seems to just embed the bitmap and you end
> up with a 2MB file as opposed to the attached SVG file.
>
> Searching google, I came across this thread -
> http://old.nabble.com/Fwd:--SVG-to-EMF-quality-p25867395.html.
> I've tried compiling the code in the thread to accomplish this, but I am
> left with an unsatisifed link error for the draw function. It's been a
> long time since I worked with MSVC!

In the example in the above linked thread the draw() function is a
function you supply for performing the cairo drawing operations.

> I was wondering if anyone has code that I could compile (or possibly
> execute) on Windows - and whether this will produce an EMF file of a
> similar size to the SVG file ( HEP also produces similar sized pdf and
> eps files - just not emf) - or if it will also balloon to 2MB.

I'm guessing that the reason for the file size difference is that the
image data in the EMF file is uncompressed. The SVG you attach contains
an embedded PNG with a compressed image.

You could try the new cairo_surface_set_mime_data() function in 1.9.6
that allows compressed image data to be provided for use by the backend
where supported. The StretchDIBits() GDI function used by the win32
printing surface for drawing images supports the PNG and JPG mime types.

Since an EMF file is simply a recording of the GDI function calls used
for drawing the graphics, the use of cairo_surface_set_mime_data()
should allow compressed PNG or JPG images to be stored in an EMF file.
But I have not tested this myself.


More information about the cairo mailing list