def analyze_pages(file_name, char_margin=<NUM_LIT:1.0>):
log = logging.getLogger(__name__)<EOL>with open(os.path.realpath(file_name), "<STR_LIT:rb>") as fp:<EOL><INDENT>parser = PDFParser(fp)<EOL>document = PDFDocument(parser, password="<STR_LIT>")<EOL>rsrcmgr = PDFResourceManager()<EOL>laparams = LAParams(<EOL>char_margin=char_margin, word_margin=<NUM_LIT:0.1>, detect_vertical=True<EOL>)<EOL>device = CustomPDFPageAggregator(rsrcmgr, laparams=laparams)<EOL>interpreter = PDFPageInterpreter(rsrcmgr, device)<EOL>for page_num, page in enumerate(PDFPage.create_pages(document)):<EOL><INDENT>try:<EOL><INDENT>interpreter.process_page(page)<EOL><DEDENT>except OverflowError as oe:<EOL><INDENT>log.exception(<EOL>"<STR_LIT>".format(oe, page_num, file_name)<EOL>)<EOL>continue<EOL><DEDENT>layout = device.get_result()<EOL>yield layout<EOL><DEDENT><DEDENT>
Input: the file path to the PDF file
Output: yields the layout object for each page in the PDF