summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/print.cpp
diff options
context:
space:
mode:
authorNicolas Dufour <nicoduf@yahoo.fr>2009-08-12 06:45:56 +0000
committerJazzyNico <JazzyNico@users.sourceforge.net>2009-08-12 06:45:56 +0000
commita36ae9f53eb376e246ff02d295796a6fead04eab (patch)
tree506a73070adbfa33c49ac2ef954fda98226d7962 /src/ui/dialog/print.cpp
parentDeweirdification of user visible messages as proposed by Tav (diff)
downloadinkscape-a36ae9f53eb376e246ff02d295796a6fead04eab.tar.gz
inkscape-a36ae9f53eb376e246ff02d295796a6fead04eab.zip
Fix for Bug #373309 (Print has offset on page), by Adrian Johnson.
(bzr r8469)
Diffstat (limited to 'src/ui/dialog/print.cpp')
-rw-r--r--src/ui/dialog/print.cpp21
1 files changed, 20 insertions, 1 deletions
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 <io.h>
+#include <windows.h>
#endif
#include <gtkmm/stock.h>
@@ -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);