cups printbackend: create a pdf surface when appropriate

This should address bug 560177.
Based on a patch by Adrian Johnson.
This commit is contained in:
Matthias Clasen 2011-01-03 09:34:04 -05:00
parent a493fad990
commit 7537907baf

View File

@ -340,10 +340,11 @@ cups_printer_create_cairo_surface (GtkPrinter *printer,
ppd_attr_t *ppd_attr_screen_freq = NULL;
ppd_attr_t *ppd_attr_res_screen_freq = NULL;
gchar *res_string = NULL;
int level = 2;
/* TODO: check if it is a ps or pdf printer */
gint level = 2;
if (gtk_printer_accepts_pdf (printer))
surface = cairo_pdf_surface_create_for_strean (_cairo_write_to_cups, cache_io, width, height);
else
surface = cairo_ps_surface_create_for_stream (_cairo_write_to_cups, cache_io, width, height);
ppd_file = gtk_printer_cups_get_ppd (GTK_PRINTER_CUPS (printer));
@ -398,11 +399,14 @@ cups_printer_create_cairo_surface (GtkPrinter *printer,
gtk_print_settings_set_printer_lpi (settings, atof (ppd_attr_screen_freq->value));
}
if (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_PS)
{
if (level == 2)
cairo_ps_surface_restrict_to_level (surface, CAIRO_PS_LEVEL_2);
if (level == 3)
cairo_ps_surface_restrict_to_level (surface, CAIRO_PS_LEVEL_3);
}
cairo_surface_set_fallback_resolution (surface,
2.0 * gtk_print_settings_get_printer_lpi (settings),