+ // Notice that we may change the Cairo transformation matrix only here and
+ // not before (e.g. in wxGtkPrinterDCImpl ctor as we used to do) in order
+ // to not affect _gtk_print_context_rotate_according_to_orientation() which
+ // is used in GTK+ itself and wouldn't work correctly if we applied these
+ // transformations before it is called.
+
+ // By default the origin of the Cairo context is in the upper left
+ // corner of the printable area. We need to translate it so that it
+ // is in the upper left corner of the paper (without margins)
+ GtkPageSetup *setup = gtk_print_context_get_page_setup( m_gpc );
+ gdouble ml, mt;
+ ml = gtk_page_setup_get_left_margin (setup, GTK_UNIT_POINTS);
+ mt = gtk_page_setup_get_top_margin (setup, GTK_UNIT_POINTS);
+ cairo_translate(m_cairo, -ml, -mt);
+
+#if wxCAIRO_SCALE
+ cairo_scale( m_cairo, 72.0 / (double)m_resolution, 72.0 / (double)m_resolution );
+#endif