code: def _page_has_text(text_blocks, page_width, page_height):
      
  
      pw, ph = float(page_width), float(page_height)
  
      margin_ratio = 0.125
      interior_bbox = (
          margin_ratio * pw,  # left
          (1 - margin_ratio) * ph,  # top
          (1 - margin_ratio) * pw,  # right
          margin_ratio * ph,  # bottom  (first quadrant: bottom < top)
      )
  
      def rects_intersect(a, b):
          """
          Where (a,b) are 4-tuple rects (left-0, top-1, right-2, bottom-3)
          https://stackoverflow.com/questions/306316/determine-if-two-rectangles-overlap-each-other
          Formula assumes all boxes are in first quadrant
          """
          return a[0] < b[2] and a[2] > b[0] and a[1] > b[3] and a[3] < b[1]
  
      has_text = False
      for bbox in text_blocks:
          if rects_intersect(bbox, interior_bbox):
              has_text = True
              break
      return has_text
docs: Smarter text detection that ignores text in margins