docs: def print_page_cb(self, print_op, print_context, keep_refs={}):
          """
          Called for printing operation by Gtk
          """
          ORIENTATION_PORTRAIT = 0
          ORIENTATION_LANDSCAPE = 1
          scaling = 2.0
  
          img = self.img
          (width, height) = img.size
  
          # take care of rotating the image if required
          if print_context.get_width() <= print_context.get_height():
              print_orientation = ORIENTATION_PORTRAIT
          else:
              print_orientation = ORIENTATION_LANDSCAPE
          if width <= height:
              img_orientation = ORIENTATION_PORTRAIT
          else:
              img_orientation = ORIENTATION_LANDSCAPE
          if print_orientation != img_orientation:
              logger.info("Rotating the page ...")
              img = img.rotate(90, expand=True)
  
          (width, height) = img.size
  
          # scale the image down
          # XXX(Jflesch): beware that we get floats for the page size ...
          scaling = min(
              print_context.get_width() / width,
              print_context.get_height() / height
          )
  
          logger.info("DPI: %fx%f" % (print_context.get_dpi_x(),
                                      print_context.get_dpi_y()))
  
          surface = image2surface(img)
          keep_refs['surface_cache_' + str(self.page_nb)] = surface
  
          # .. and print !
          cairo_context = print_context.get_cairo_context()
          cairo_context.scale(scaling, scaling)
          cairo_context.set_source_surface(surface, 0, 0)
          cairo_context.paint()