Printing with GTK/Cairo produces only empty pages



Hi,

I try to print some vector data using GTK/Cairo. Unfortunately my
printer only produces empty pages, means there is no print operation,
the paper sheets are just moved.

That's how I'm initialising everything:

GtkPrintOperation *op;

op = gtk_print_operation_new();
gtk_print_operation_set_allow_async(op,TRUE);
gtk_print_operation_set_n_pages(op, 1);
gtk_print_operation_set_unit (op,GTK_UNIT_POINTS);
g_signal_connect (op, "draw_page", G_CALLBACK(draw_page), NULL);
gtk_print_operation_run (op, GTK_PRINT_OPERATION_ACTION_PRINT,NULL, NULL);

The print-callback (which is called successfuly) looks like this:

static void draw_page (GtkPrintOperation *operation,GtkPrintContext
*context,int page_nr)
{
   GtkPrintSettings *settings;

   cairo_t *cr = gtk_print_context_get_cairo_context (context);
   settings = gtk_print_operation_get_print_settings (operation);
   cairo_set_source_rgb(dc,0,0,0);
   cairo_set_line_width(dc,m_data->config.m_linewidth);

   cairo_move_to (cr,x0,y0);
   cairo_line_to (cr,x1,y1);
   cairo_line_to (cr,x2,y2);
   ...
   // some more lines...
}

What could be missing here? Do I have to close/finish the drawing
operation somehow?

Thanks!


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]