def display_boxes(self, pdf_file, boxes, alternate_colors=False):
imgs = []<EOL>colors = [Color("<STR_LIT>"), Color("<STR_LIT>")]<EOL>boxes_per_page = defaultdict(int)<EOL>boxes_by_page = defaultdict(list)<EOL>for i, (page, top, left, bottom, right) in enumerate(boxes):<EOL><INDENT>boxes_per_page[page] += <NUM_LIT:1><EOL>boxes_by_page[page].append((top, left, bottom, right))<EOL><DEDENT>for i, page_num in enumerate(boxes_per_page.keys()):<EOL><INDENT>img = pdf_to_img(pdf_file, page_num)<EOL>draw = Drawing()<EOL>draw.fill_color = Color("<STR_LIT>")<EOL>for j, (top, left, bottom, right) in enumerate(boxes_by_page[page_num]):<EOL><INDENT>draw.stroke_color = colors[j % <NUM_LIT:2>] if alternate_colors else colors[<NUM_LIT:0>]<EOL>draw.rectangle(left=left, top=top, right=right, bottom=bottom)<EOL><DEDENT>draw(img)<EOL>imgs.append(img)<EOL><DEDENT>return imgs<EOL>
Displays each of the bounding boxes passed in 'boxes' on images of the pdf
pointed to by pdf_file
boxes is a list of 5-tuples (page, top, left, bottom, right)