def display_bounding_boxes_within_notebook(
    page_num, extractor, blocks, alternatecolors=False, color=Color("blue")
):
    """
    Displays each of the bounding boxes passed in 'boxes' on an image of the pdf
    pointed to by pdf_file
    boxes is a list of 5-tuples (page, top, left, bottom, right)
    """
    elems = extractor.elems[page_num]
    page_width, page_height = int(elems.layout.width), int(elems.layout.height)
    img = pdf_to_img(extractor.pdf_file, page_num, page_width, page_height)
    draw = Drawing()
    draw.fill_color = Color("rgba(0, 0, 0, 0)")
    draw.stroke_color = color
    for block in blocks:
        top, left, bottom, right = block[-4:]
        if alternatecolors:
            draw.stroke_color = Color(
                "rgba({},{},{}, 1)".format(
                    str(np.random.randint(255)),
                    str(np.random.randint(255)),
                    str(np.random.randint(255)),
                )
            )
        draw.rectangle(
            left=float(left), top=float(top), right=float(right), bottom=float(bottom)
        )
        draw(img)
    return img
def display_bounding_boxes_within_notebook ( page_num , extractor , blocks , alternatecolors = False , color = Color ( "blue" ) ) : elems = extractor . elems [ page_num ] page_width , page_height = int ( elems . layout . width ) , int ( elems . layout . height ) img = pdf_to_img ( extractor . pdf_file , page_num , page_width , page_height ) draw = Drawing ( ) draw . fill_color = Color ( "rgba(0, 0, 0, 0)" ) draw . stroke_color = color for block in blocks : top , left , bottom , right = block [ - 4 : ] if alternatecolors : draw . stroke_color = Color ( "rgba({},{},{}, 1)" . format ( str ( np . random . randint ( 255 ) ) , str ( np . random . randint ( 255 ) ) , str ( np . random . randint ( 255 ) ) , ) ) draw . rectangle ( left = float ( left ) , top = float ( top ) , right = float ( right ) , bottom = float ( bottom ) ) draw ( img ) return img
Displays each of the bounding boxes passed in 'boxes' on an image of the pdf
    pointed to by pdf_file
    boxes is a list of 5-tuples (page, top, left, bottom, right)