+2007-08-27 Carlos Garcia Campos <carlosgc@gnome.org>
+
+ * backend/pdf/ev-poppler.cc: (pdf_print_context_free),
+ (pdf_document_file_exporter_begin),
+ (pdf_document_file_exporter_do_page):
+ * shell/ev-jobs.c: (ev_job_print_run):
+ * shell/ev-window.c: (ev_window_print_dialog_response_cb):
+
+ Create always a portrait cairo surface and rotate when needed for
+ landscape. It fixes printing problems in real printers.
+
2007-08-25 Carlos Garcia Campos <carlosgc@gnome.org>
* backend/pdf/ev-poppler.cc: (pdf_document_file_exporter_begin):
typedef struct {
EvFileExporterFormat format;
- PopplerPSFile *ps_file;
+ gboolean landscape;
+
/* Pages per sheet */
gint pages_per_sheet;
gint pages_printed;
#ifdef HAVE_CAIRO_PRINT
cairo_t *cr;
+#else
+ PopplerPSFile *ps_file;
#endif
} PdfPrintContext;
if (!ctx)
return;
- if (ctx->ps_file) {
- poppler_ps_file_free (ctx->ps_file);
- ctx->ps_file = NULL;
- }
#ifdef HAVE_CAIRO_PRINT
if (ctx->cr) {
cairo_destroy (ctx->cr);
ctx->cr = NULL;
}
+#else
+ if (ctx->ps_file) {
+ poppler_ps_file_free (ctx->ps_file);
+ ctx->ps_file = NULL;
+ }
#endif
g_free (ctx);
}
ctx->pages_per_sheet = fc->pages_per_sheet;
landscape = (fc->orientation == EV_FILE_EXPORTER_LANDSCAPE);
+ change_orient = landscape;
switch (fc->pages_per_sheet) {
default:
ctx->pages_y = 1;
break;
case 2:
- change_orient = TRUE;
landscape = !landscape;
ctx->pages_x = 1;
ctx->pages_y = 2;
ctx->pages_y = 2;
break;
case 6:
- change_orient = TRUE;
landscape = !landscape;
ctx->pages_x = 2;
ctx->pages_y = 3;
break;
}
+ ctx->landscape = landscape;
+
if (change_orient) {
width = fc->paper_height;
height = fc->paper_width;
width = fc->paper_width;
height = fc->paper_height;
}
-
+
if (landscape) {
gint tmp;
tmp = ctx->pages_x;
ctx->pages_x = ctx->pages_y;
ctx->pages_y = tmp;
+
+ ctx->page_width = height / ctx->pages_x;
+ ctx->page_height = width / ctx->pages_y;
+ } else {
+ ctx->page_width = width / ctx->pages_x;
+ ctx->page_height = height / ctx->pages_y;
}
-
- ctx->page_width = width / ctx->pages_x;
- ctx->page_height = height / ctx->pages_y;
ctx->pages_printed = 0;
#ifdef HAVE_CAIRO_PRINT
ctx->cr = cairo_create (surface);
+ if (landscape) {
+ cairo_matrix_t matrix;
+
+ cairo_translate (ctx->cr, width, 0);
+ cairo_matrix_init (&matrix,
+ 0, 1,
+ -1, 0,
+ 0, 0);
+ cairo_transform (ctx->cr, &matrix);
+ }
cairo_surface_destroy (surface);
#endif
}
cairo_translate (ctx->cr,
x * ctx->page_width,
y * ctx->page_height);
- cairo_scale (ctx->cr,
- ctx->page_width / page_width,
- ctx->page_height / page_height);
+ if (ctx->landscape) {
+ cairo_scale (ctx->cr,
+ ctx->page_height / page_height,
+ ctx->page_height / page_height);
+ } else {
+ cairo_scale (ctx->cr,
+ ctx->page_width / page_width,
+ ctx->page_height / page_height);
+ }
#ifdef HAVE_POPPLER_PAGE_RENDER
poppler_page_render (poppler_page, ctx->cr);
fc.paper_height = job->height;
fc.orientation = job->orientation;
fc.duplex = FALSE;
- fc.pages_per_sheet = job->pages_per_sheet;
+ fc.pages_per_sheet = MAX (1, job->pages_per_sheet);
ev_document_doc_mutex_lock ();
ev_file_exporter_begin (EV_FILE_EXPORTER (document), &fc);