GtkPrintOperation uses wrong scale on Windows ?



Hi,

GnuCash is using GtkPrintOperation (Gtk2.24) to print checks. On linux this has always worked fine, but on Windows we have major scaling problems. There is a bugreport for this [1], which I am trying to solve for quite some time now.

A check that should be printed page-wide actually appears in a tiny 1-inch area on the page. So far I have discovered that it is printer-resolution dependent. The 1-inch area is what you get when the printer's resolution is set to 600dpi. Setting the printer resolution to 72 dpi, the checks are printed properly.

I did find a cairo mailing list message [2] that suggests this would be fixed by using gtk_print_operation_set_unit() to set the unit to GTK_UNIT_POINTS, but this has already been added without any effect.

Here are some more details:

* The code that creates the print operation looks like this:

    print = gtk_print_operation_new();

    /* some code to set job title and load printer settings omitted here */

    gtk_print_operation_set_unit(print, GTK_UNIT_POINTS);
    gtk_print_operation_set_use_full_page(print, TRUE);
    g_signal_connect(print, "begin_print", G_CALLBACK(begin_print), pcd);
    g_signal_connect(print, "draw_page", G_CALLBACK(draw_page), pcd);

    res = gtk_print_operation_run(print,
                                  GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
                                  pcd->caller_window, NULL);

* The callback "begin_print" calculates the number of pages to print, based on a simple algorithm that a fixed number of checks fits on one page. Nothing in this code could have any effect on the resolution

* At the beginning of the "draw_page" callback I have added some diagnostic debug messages:

    PINFO("width: %f, xres: %f, yres: %f",
          gtk_print_context_get_width (context),
          gtk_print_context_get_dpi_x (context),
          gtk_print_context_get_dpi_y (context));

Which would print this line to our debug output (for a 600dpi printer resolution): INFO <gnc.printing.checks> [draw_page] width: 595,275591, xres: 600,000000, yres: 600,000000

This matches the result on paper: 595 units at 600dpi is about 1 inch, but is clearly not what we had in mind. 595 units roughly matches the width of a US letter paper minus margins at 72 dpi.

As I understood, setting unit to GTK_UNIT_POINTS via gtk_print_operation_set_unit should have changed all this: I would either have expected a resolution of 72 dpi or a much larger page width.

As said before, this is all using Gtk 2.24, and on linux this works fine. The debug line on linux gives this: INFO <gnc.printing.checks> [draw_page] width: 595.275591, xres: 72.000000, yres: 72.000000

Am I doing something wrong here ?

Thanks,

Geert

[1] https://bugzilla.gnome.org/show_bug.cgi?id=631611
[2] http://comments.gmane.org/gmane.comp.lib.cairo/19686



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]