fitz_doc = fitz.open(f"{PATH}/files/timetables/input/{title}")
fitz_page = fitz_doc[0]
page_box = fitz_page.cropbox
if students[0].get("corpus_1") and doc["corpus"] == "1":
groups = students[0]["corpus_1"]
for group in groups:
fitz_page.set_mediabox(page_box)
group_name = group["group_name"]
try:
coords = fitz_page.search_for(group_name)[0]
#highlight = fitz_page.add_rect_annot(coords)
x0, y0, x1, y1 = coords
fitz_page.set_cropbox(fitz.Rect(x0-20, y0-15, x1+70, y1+170).round() )
fitz_page.get_pixmap(matrix = magnify).save(f"{PATH}/files/timetables/output/{group_name}.png")
except Exception as error:
print(error)
print(f"{group_name} Error")