Re: Windows printing problem

2010-08-22 Thread James
On Fri, 2010-08-20 at 15:55 +1000, James wrote:
 Hi,
 
 I've refined the code a bit.
 
 This I can print to PDF using pdfFactory Pro, and it is displayed in the
 pdfFactory Pro preview window properly, but Windows always errors out on
 the actual printing.
 
 Printing direct to the printer (HP laserjet) also causes windows to
 report an error trying to print.
 
 (The printer works fine for every other app on Windows and Ubuntu).
 
 Draw page code below.

snip

Ok, I think I found the reason the darn thing wont print under windows.
It seems that because I have about 1 lines drawn in cairo onto the
print surface, the printer chucks a fit.  Now I draw to a separate cairo
surface and copy to the print context, which generates somewhat fuzzy
lines, but at least works.

Is there something I can do to improve the fuzzy lines?

James.

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Windows printing problem

2010-08-19 Thread James
Hi,

I've refined the code a bit.

This I can print to PDF using pdfFactory Pro, and it is displayed in the
pdfFactory Pro preview window properly, but Windows always errors out on
the actual printing.

Printing direct to the printer (HP laserjet) also causes windows to
report an error trying to print.

(The printer works fine for every other app on Windows and Ubuntu).

Draw page code below.

Regards,
James.

static void draw_page (GtkPrintOperation *operation,
GtkPrintContext   *context,
gint   page_nr,
gpointer   user_data)
{
g_print(Draw page %d\n, page_nr);


int i;
char text[256];
int len;
PangoLayout *layout;
PangoFontDescription *desc;
GError *gerror = NULL;
GdkPixbuf *pb;

cairo_t *cr;
gdouble width, height;

cr = gtk_print_context_get_cairo_context (context);
width = gtk_print_context_get_width (context);
height = gtk_print_context_get_height (context);

pb = gdk_pixbuf_new_from_file(./Logo.jpg, gerror);
if(!pb) {
eprintf(error message: %s\n, gerror-message);
return;
}

int pb_width = gdk_pixbuf_get_width (pb);
int pb_height = gdk_pixbuf_get_height (pb);

cairo_operator_t op = cairo_get_operator(cr);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
gdk_cairo_set_source_pixbuf(cr, pb, 0.0, 0.0);
cairo_paint (cr);
cairo_set_operator(cr, op);

cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);

layout = gtk_print_context_create_pango_layout (context);
desc = pango_font_description_from_string (sans 14);
pango_layout_set_font_description (layout, desc);

sprintf(text, Title details);

cairo_move_to(cr, pb_width+10, 0);
pango_layout_set_text (layout, text, -1);
pango_cairo_update_layout (cr, layout);
pango_cairo_show_layout (cr, layout);

pango_layout_set_text (layout, text, -1);

pango_font_description_free (desc);
g_object_unref (layout);

for (i = 0; i  6; i++) {
layout = gtk_print_context_create_pango_layout (context);

len = 0;
len += sprintf(text[len], Stuff\n);
len += sprintf(text[len], More stuff\n);

pango_layout_set_text (layout, text, -1);

desc = pango_font_description_from_string (sans 9);
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
pango_cairo_update_layout (cr, layout);

cairo_move_to(cr, (5 - i) * (width - GAP_X_AXIS) / 6, height - 
80);
pango_cairo_show_layout (cr, layout);

g_object_unref (layout);
}

cairo_translate(cr, 0, pb_height);

if (page_nr == 0) {
#if 1
//Various text and line drawing 
//with pango and cairo functions.
#endif
} else if (page_nr == 1) {
#if 1
//Various text and line drawing 
//with pango and cairo functions.
#endif
}
}


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list