[cairo] EMF output?

Vladimir Vukicevic vladimir at pobox.com
Sun Feb 25 15:29:10 PST 2007


Jan Struyf wrote:
> 
> Dear All,
> 
> I would like to use the Cairo library save graphs, diagrams and 
> technical drawings in various vector and possibly bitmap formats. 
> Besides SVG and PDF output, I'm also very much interested in EMF because 
> this would allow me to copy and paste graphics to various Windows 
> applications.
> 
> I was wondering if the Win32 surface is useful for this. Is this a 
> bitmap surface or is it really a vector surface? Given that I'm mainly 
> interested in this for technical drawings, saving in vector format is 
> important, even if not all effects are perfectly rendered in this way.

Are you sure?  Saving in EMF/PDF isn't all that useful, because it's 
very hard to modify the data afterwards.  Unless you're talking about 
just saving for output only, in which case PDF would be far superior 
than EMF for that purpose.  The only thing that you'd lose is the 
ability to move EMF/vector data using the clipboard; I'm honestly not 
aware of too many apps that can do something useful with that, other 
than, say, pasting an EMF into a word processing document.

> I found a thread about a patch contributed by Hans Breuer and it appears 
> that this patch is related to my question because it defines vector 
> operations for EMF output:
> 
> <http://lists.freedesktop.org/archives/cairo/2005-February/002936.html>
> 
> Has this patch or similar functionality been integrated into Cairo? Or 
> is this still a difficult matter? I understood that there is a balance 
> between approximating the intended drawing with the supported primitives 
> by the target format or rendering parts of the drawing as a bitmap and 
> that this is especially difficult for EMF.

To support EMF rendering, you'd pretty much need a completely new win32 
surface that's expressly for EMF rendering; it would need to hook into a 
different layer of the cairo stack to be able to do it.  A GDI+ surface 
might be useful for this, since (I believe?) you can render to a 
metafile using GDI+ but I'm not positive.  I'm not sure about that patch 
from 2005; there is a current win32 surface which is GDI only, renders 
to bitmaps, and accelerates what it can using GDI functions and hands 
the rest to fallback code.

     - vlad


More information about the cairo mailing list