Re: Printing with GTK/Cairo produces only empty pages
- From: Chris Vine <chris cvine freeserve co uk>
- To: Satz Klauer <satzklauer googlemail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Printing with GTK/Cairo produces only empty pages
- Date: Mon, 14 Oct 2013 18:55:18 +0100
On Mon, 14 Oct 2013 19:34:53 +0200
Satz Klauer <satzklauer googlemail com> wrote:
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?
That depends on what you are trying to draw. I suspect you are looking
for cairo_stroke(), but you could also consider cairo_fill(). Note also
the *_preserve() variants.
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]