From 87aebcec5c3d1b1fe028518f2e21e675963a6a27 Mon Sep 17 00:00:00 2001 From: JazzyNico Date: Wed, 12 Aug 2009 06:45:56 +0000 Subject: [PATCH] Fix for Bug #373309 (Print has offset on page), by Adrian Johnson. --- src/ui/dialog/print.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index d15773ecb..214b1a6db 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -13,6 +13,7 @@ #endif #ifdef WIN32 #include +#include #endif #include @@ -31,7 +32,7 @@ static void -draw_page (GtkPrintOperation */*operation*/, +draw_page (GtkPrintOperation *operation, GtkPrintContext *context, gint /*page_nr*/, gpointer user_data) @@ -106,6 +107,24 @@ draw_page (GtkPrintOperation */*operation*/, cairo_surface_t *surface = cairo_get_target(cr); cairo_matrix_t ctm; cairo_get_matrix(cr, &ctm); +#ifdef WIN32 + //Gtk+ does not take the non printable area into account + //http://bugzilla.gnome.org/show_bug.cgi?id=381371 + // + // This workaround translates the origin from the top left of the + // printable area to the top left of the page. + GtkPrintSettings *settings = gtk_print_operation_get_print_settings(operation); + const gchar *printerName = gtk_print_settings_get_printer(settings); + HDC hdc = CreateDC("WINSPOOL", printerName, NULL, NULL); + if (hdc) { + cairo_matrix_t mat; + int x_off = GetDeviceCaps (hdc, PHYSICALOFFSETX); + int y_off = GetDeviceCaps (hdc, PHYSICALOFFSETY); + cairo_matrix_init_translate(&mat, -x_off, -y_off); + cairo_matrix_multiply (&ctm, &ctm, &mat); + DeleteDC(hdc); + } +#endif bool ret = ctx->setSurfaceTarget (surface, true, &ctm); if (ret) { ret = renderer.setupDocument (ctx, junk->_doc, TRUE, NULL); -- 2.30.2