]> www.fi.muni.cz Git - evince.git/commitdiff
Create always a portrait cairo surface and rotate when needed for
authorCarlos Garcia Campos <carlosgc@gnome.org>
Mon, 27 Aug 2007 18:11:30 +0000 (18:11 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Mon, 27 Aug 2007 18:11:30 +0000 (18:11 +0000)
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.

svn path=/trunk/; revision=2643

ChangeLog
backend/pdf/ev-poppler.cc
shell/ev-jobs.c
shell/ev-window.c

index d95b6e176cb586ac774324fba3988c22a90738f8..da4744d9ca0fc0751bd592379e79bc637a93bc1c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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):
index cc6137b11be2d0bef8271aa4fec08084f47de800..815862cb096930f01344a673f536d6c0f54dd840 100644 (file)
@@ -67,8 +67,9 @@ typedef struct {
 
 typedef struct {
        EvFileExporterFormat format;
-       PopplerPSFile *ps_file;
 
+       gboolean landscape;
+       
        /* Pages per sheet */
        gint pages_per_sheet;
        gint pages_printed;
@@ -79,6 +80,8 @@ typedef struct {
        
 #ifdef HAVE_CAIRO_PRINT
        cairo_t *cr;
+#else
+       PopplerPSFile *ps_file;
 #endif
 } PdfPrintContext;
 
@@ -1559,15 +1562,16 @@ pdf_print_context_free (PdfPrintContext *ctx)
        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);
 }
@@ -1592,6 +1596,7 @@ pdf_document_file_exporter_begin (EvFileExporter        *exporter,
        ctx->pages_per_sheet = fc->pages_per_sheet;
 
        landscape = (fc->orientation == EV_FILE_EXPORTER_LANDSCAPE);
+       change_orient = landscape;
        
        switch (fc->pages_per_sheet) {
                default:
@@ -1600,7 +1605,6 @@ pdf_document_file_exporter_begin (EvFileExporter        *exporter,
                        ctx->pages_y = 1;
                        break;
                case 2:
-                       change_orient = TRUE;
                        landscape = !landscape;
                        ctx->pages_x = 1;
                        ctx->pages_y = 2;
@@ -1610,7 +1614,6 @@ pdf_document_file_exporter_begin (EvFileExporter        *exporter,
                        ctx->pages_y = 2;
                        break;
                case 6:
-                       change_orient = TRUE;
                        landscape = !landscape;
                        ctx->pages_x = 2;
                        ctx->pages_y = 3;
@@ -1625,6 +1628,8 @@ pdf_document_file_exporter_begin (EvFileExporter        *exporter,
                        break;
        }
 
+       ctx->landscape = landscape;
+
        if (change_orient) {
                width = fc->paper_height;
                height = fc->paper_width;
@@ -1632,17 +1637,20 @@ pdf_document_file_exporter_begin (EvFileExporter        *exporter,
                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;
 
@@ -1669,6 +1677,16 @@ pdf_document_file_exporter_begin (EvFileExporter        *exporter,
 
 #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
 }
@@ -1698,9 +1716,15 @@ pdf_document_file_exporter_do_page (EvFileExporter  *exporter,
        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);
index c78b28cbf358193b18798bd40058ec632e9d7f18..6934f60f71ed79e1c5dbf96eae104754d275eb1c 100644 (file)
@@ -720,7 +720,7 @@ ev_job_print_run (EvJobPrint *job)
        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);
index 970074677e0bbf5e7e2a619e9f12256c4c2d0fa0..32d52fdaa67d73ceafe4ca06379b44ed8c54c211 100644 (file)
@@ -2332,7 +2332,7 @@ ev_window_print_dialog_response_cb (GtkDialog *dialog,
        gdouble        width;
        gdouble        height;
        GtkPrintPages  print_pages;
-       EvFileExporterOrientation orientation;
+       EvFileExporterOrientation orientation = EV_FILE_EXPORTER_PORTRAIT;
        const gchar   *file_format;
        
        if (response == GTK_RESPONSE_CANCEL) {