How to use the pdfplumber.utils.intersects_bbox function in pdfplumber

To help you get started, we’ve selected a few pdfplumber examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jsvine / pdfplumber / tests / test-la-precinct-bulletin-2014-p1.py View on Github external
def precinct(self):
        h1_left = list(self.bboxes["h1"])
        h1_left[-2] = float(h1_left[-2]) / 2
        h1_left_chars = intersects_bbox(self.chars, h1_left)
        txt = h1_left_chars.groupby("top").apply(collate_chars).iloc[-1]
        p_id = "|".join(re.split(r"\s{2,}", txt)[1:3])
        return p_id
github jsvine / pdfplumber / pdfplumber / table.py View on Github external
overlap = False
        for c in condensed_rects:
            if utils.objects_overlap(rect, c):
                overlap = True
                break
        if overlap == False:
            condensed_rects.append(rect)
            
    if len(condensed_rects) == 0:
        return []
    sorted_rects = list(sorted(condensed_rects, key=itemgetter("x0")))

    # Find the far-right boundary of the rightmost rectangle
    last_rect = sorted_rects[-1]
    while True:
        words_inside = utils.intersects_bbox(
            [ w for w in words if w["x0"] >= last_rect["x0"] ],
            (last_rect["x0"], last_rect["top"], last_rect["x1"], last_rect["bottom"]), 
        )
        rect = utils.objects_to_rect(words_inside)
        if rect == last_rect:
            break
        else:
            last_rect = rect
    
    # Describe all the left-hand edges of each text cluster
    edges = [ {
        "x0": b["x0"],
        "x1": b["x0"],
        "top": b["top"],
        "bottom": b["bottom"],
        "height": b["bottom"] - b["top"],