using gtkprint for images
- From: Allin Cottrell <cottrell wfu edu>
- To: gtk-app-devel-list gnome org
- Subject: using gtkprint for images
- Date: Thu, 30 Aug 2007 17:29:43 -0400 (EDT)
I just took a first serious look at the gtkprint API.  I must say 
it works very nicely and is quite easy to learn, at least as 
regards printing text.
My first problem: I have a window displaying the content of a PNG 
file, and I'd like to offer the option of printing the PNG.  How 
to do this?
I tried connecting the "begin_print" signal to this callback
(I've stripped out several checks for quick legibility):
static void begin_image_print (GtkPrintOperation *op,
                               GtkPrintContext *context,
                               char *pngname)
{
    cairo_surface_t *cs;
    cairo_t *cr;
    cs = cairo_image_surface_create_from_png(pngname);
    cr = cairo_create(cs);
    gtk_print_context_set_cairo_context(context, cr, 72, 72);
    gtk_print_operation_set_n_pages(op, 1);
}
By running a verbose version of the above I've verified that cairo 
is happily creating a 640x480 surface of type CAIRO_FORMAT_ARGB32 
based on the PNG file, and successfully making a cairo_t out of 
it.
But then I'm not sure what, if anything, to put in a callback for 
the "draw_page" signal: it sort of seems like there should be 
nothing left to do.  I tried just making the callback just a stub 
that prints "got draw_page".  But I get a blank PDF on output.
Suggestions gratefully received.
-- 
Allin Cottrell
Department of Economics
Wake Forest University, NC
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]