[cairo] Welding Cairo with Mac OS X printing

Baz brian.ewins at gmail.com
Fri Dec 7 12:11:43 PST 2007


On Dec 7, 2007 7:22 PM, Travis Griggs <tgriggs at cincom.com> wrote:
> This is somewhat off topic, I apologize, I thought I'd start here,
> and then go off channel if I could get any response.
>
> I was looking at a guy's app the other day that uses our rather old
> graphics APIs to print stuff on OSX. It got my wondering if I
> couldn't do some nicer stuff with Cairo. I know Cairo decently well
> these days. But not OSX printing machinery. Does anyone on list have
> any idea how hard it would be to open an OSX printer dialog, get the
> printer, and then squirt Cairo generated graphics at it?

Not really - I don't own a printer (tree murderer!! ;) ). But it
doesn't look difficult. As usual, you just need to get hold of a
CGContext, and create your cairo context with that; the API you're
looking for is PrintManager's PMSessionGetCGGraphicsContext.
http://developer.apple.com/documentation/GraphicsImaging/Reference/CorePrintRef/Reference/reference.html#//apple_ref/c/func/PMSessionGetCGGraphicsContext

In the apple docs you can find code for writing the printing loop (and
dealing with print dialogs) here:
http://developer.apple.com/documentation/Carbon/Conceptual/CPM_Concepts/index.html#//apple_ref/doc/uid/TP30000978

that code uses a QT context, you'll want to plug in the call to
PMSessionGetCGGraphicsContext where they have
PMSessionGetGraphicsContext, and do your cairo work in the block
immediately after that.

I believe this is how firefox works, and that gnome don't do printing
on OS X yet. This won't do any pagination for you btw, and you'll be
hitting any limitations of the quartz surface, not the pdf, ps
surfaces.

>
> TIA
>
> --
> Travis Griggs
> Objologist
> "I choose. Therefore, I Am"
>
>
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>


More information about the cairo mailing list