code: def make_grid_from_positions(colpos, rowpos):
      """
      Create a page grid from list of column positions <colpos> and a list of row positions <rowpos>.
      Both positions lists must be sorted from low to high!
      The returned page grid is a list of rows. Each row in turn contains a "grid cell",
      i.e. a rect (see pdftabextract.geom).
      """
      if len(colpos) == 0:
          raise ValueError("List of column positions is empty.")
      if len(rowpos) == 0:
          raise ValueError("List of row positions is empty.")
  
      row_spans = subsequent_pairs(rowpos)
      col_spans = subsequent_pairs(colpos)
  
      # create a grid with rectangles of table cells
      grid = []
  
      for top, bottom in row_spans:
          row = []
          for left, right in col_spans:
              cell = rect(pt(left, top), pt(right, bottom))
              row.append(cell)
          grid.append(row)
  
      return grid
  
imports: from collections import defaultdict, OrderedDict
  from pdftabextract.geom import pt, rect, rect_from_text, rectintersect, rectcenter_dist
  from pdftabextract.textboxes import join_texts, create_text_from_lines, put_texts_in_lines
label_desc: Use image node_id 1 for calling a global function with example usage: make_grid_from_positions(colpos, rowpos) and returns: grid