code: def export_cairo(self, filepath, filetype):
          
  
          if cairo is None:
              return
  
          export_info = \
              self.main_window.interfaces.get_cairo_export_info(filetype)
  
          if export_info is None:
              # Dialog has been canceled
              return
  
          top_row = max(0, export_info["top_row"])
          bottom_row = min(self.grid.code_array.shape[0] - 1,
                           export_info["bottom_row"])
          left_col = max(0, export_info["left_col"])
          right_col = min(self.grid.code_array.shape[1] - 1,
                          export_info["right_col"])
          first_tab = max(0, export_info["first_tab"])
          last_tab = min(self.grid.code_array.shape[2] - 1,
                         export_info["last_tab"])
          width = export_info["paper_width"]
          height = export_info["paper_height"]
          orientation = export_info["orientation"]
  
          if orientation == "landscape":
              width, height = height, width
  
          if filetype == "pdf":
              surface = cairo.PDFSurface(filepath, width, height)
          elif filetype == "svg":
              surface = cairo.SVGSurface(filepath, width, height)
          else:
              msg = "Export filetype {filtype} not supported.".format(
                  filetype=filetype)
              raise ValueError(msg)
  
          context = cairo.Context(surface)
  
          grid_cairo_renderer = GridCairoRenderer(
              context,
              self.code_array,
              (top_row, bottom_row + 1),
              (left_col, right_col + 1),
              (first_tab, last_tab + 1),
              width,
              height,
              orientation,
              view_frozen=self.grid._view_frozen,
          )
  
          grid_cairo_renderer.draw()
  
          # Finish is required for matplotlib figures
          surface.finish()
docs: Exports grid to the PDF file filepath
  
          Parameters
          ----------
          filepath: String
          \tPath of file to export
          filetype in ["pdf", "svg"]
          \tType of file to export