--- a/gtk/gtkpagesetup.c
+++ b/gtk/gtkpagesetup.c
@@ -485,10 +485,14 @@ gtk_page_setup_get_page_width (GtkPageSetup *setup,
 			       GtkUnit       unit)
 {
   gdouble width;
-  
+
   width = gtk_page_setup_get_paper_width (setup, GTK_UNIT_MM);
-  width -= setup->left_margin + setup->right_margin;
-  
+  if (setup->orientation == GTK_PAGE_ORIENTATION_PORTRAIT ||
+      setup->orientation == GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT)
+    width -= setup->left_margin + setup->right_margin;
+  else
+    width -= setup->top_margin + setup->bottom_margin;
+
   return _gtk_print_convert_from_mm (width, unit);
 }
 
@@ -512,10 +516,14 @@ gtk_page_setup_get_page_height (GtkPageSetup *setup,
 				GtkUnit       unit)
 {
   gdouble height;
-  
+
   height = gtk_page_setup_get_paper_height (setup, GTK_UNIT_MM);
-  height -= setup->top_margin + setup->bottom_margin;
-  
+  if (setup->orientation == GTK_PAGE_ORIENTATION_PORTRAIT ||
+      setup->orientation == GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT)
+    height -= setup->top_margin + setup->bottom_margin;
+  else
+    height -= setup->left_margin + setup->right_margin;
+
   return _gtk_print_convert_from_mm (height, unit);
 }
 
--- a/gtk/gtkprintcontext.c
+++ b/gtk/gtkprintcontext.c
@@ -317,17 +317,35 @@ _gtk_print_context_reverse_according_to_orientation (GtkPrintContext *context)
 void
 _gtk_print_context_translate_into_margin (GtkPrintContext *context)
 {
-  gdouble left, top;
+  gdouble dx, dy;
 
   g_return_if_fail (GTK_IS_PRINT_CONTEXT (context));
 
   /* We do it this way to also handle GTK_UNIT_NONE */
-  left = gtk_page_setup_get_left_margin (context->page_setup, GTK_UNIT_INCH);
-  top = gtk_page_setup_get_top_margin (context->page_setup, GTK_UNIT_INCH);
+  switch (gtk_page_setup_get_orientation (context->page_setup))
+    {
+      default:
+      case GTK_PAGE_ORIENTATION_PORTRAIT:
+        dx = gtk_page_setup_get_left_margin (context->page_setup, GTK_UNIT_INCH);
+        dy = gtk_page_setup_get_top_margin (context->page_setup, GTK_UNIT_INCH);
+        break;
+      case GTK_PAGE_ORIENTATION_LANDSCAPE:
+        dx = gtk_page_setup_get_bottom_margin (context->page_setup, GTK_UNIT_INCH);
+        dy = gtk_page_setup_get_left_margin (context->page_setup, GTK_UNIT_INCH);
+        break;
+      case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT:
+        dx = gtk_page_setup_get_right_margin (context->page_setup, GTK_UNIT_INCH);
+        dy = gtk_page_setup_get_bottom_margin (context->page_setup, GTK_UNIT_INCH);
+        break;
+      case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE:
+        dx = gtk_page_setup_get_top_margin (context->page_setup, GTK_UNIT_INCH);
+        dy = gtk_page_setup_get_right_margin (context->page_setup, GTK_UNIT_INCH);
+        break;
+    }
 
   cairo_translate (context->cr,
-                   left * context->surface_dpi_x / context->pixels_per_unit_x,
-                   top * context->surface_dpi_y / context->pixels_per_unit_y);
+                   dx * context->surface_dpi_x / context->pixels_per_unit_x,
+                   dy * context->surface_dpi_y / context->pixels_per_unit_y);
 }
 
 void
