From dad2198394fd670864b4eb06c7d95fed297c6ad1 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Fri, 26 Feb 2016 01:07:59 -0800 Subject: [PATCH] Log information about detected page orientations in a summary line --- ocrmypdf/main.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ocrmypdf/main.py b/ocrmypdf/main.py index 91944d67..a3654e51 100755 --- a/ocrmypdf/main.py +++ b/ocrmypdf/main.py @@ -550,6 +550,12 @@ def orient_page( with open(output_file, 'wb') as out: writer.write(out) + with pdfinfo_lock: + pageno = int(os.path.basename(page_pdf)[0:6]) - 1 + pageinfo = pdfinfo[pageno].copy() + pageinfo['rotated'] = orient_conf.angle + pdfinfo[pageno] = pageinfo + @transform( input=orient_page, @@ -1057,6 +1063,20 @@ def run_pipeline(): _log.warning('Output file: The generated PDF/A file is INVALID') return ExitCode.invalid_output_pdfa + with _pdfinfo_lock: + _log.debug(_pdfinfo) + direction = {0: 'n', 90: 'e', + 180: 's', 270: 'w'} + orientations = [] + for n, page in enumerate(_pdfinfo): + angle = _pdfinfo[n].get('rotated', 0) + if angle != 0: + orientations.append('{0}{1}'.format( + n + 1, + direction.get(angle, ''))) + if orientations: + _log.info('Page orientations detected: ' + ' '.join(orientations)) + return ExitCode.ok