From 42cd683ec072275a36b125191c18a362a384c26a Mon Sep 17 00:00:00 2001 From: Jim Barlow Date: Sat, 25 Jul 2015 02:47:59 -0700 Subject: [PATCH] Try to make pdfinfo less obnoxious by printing too many decimals --- src/ocrmypdf.py | 2 -- src/pageinfo.py | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ocrmypdf.py b/src/ocrmypdf.py index c6a67095..d237544f 100755 --- a/src/ocrmypdf.py +++ b/src/ocrmypdf.py @@ -277,8 +277,6 @@ def repair_pdf( log.info(pdfinfo) -# pageno, width_pt, height_pt = map(int, options.page_info.split(' ', 3)) -# pageinfo = pdf_get_pageinfo(options.input_file, pageno, width_pt, height_pt) # if not pageinfo['images']: # # If the page has no images, then it contains vector content or text diff --git a/src/pageinfo.py b/src/pageinfo.py index 364af994..6536be75 100644 --- a/src/pageinfo.py +++ b/src/pageinfo.py @@ -3,7 +3,7 @@ from subprocess import Popen, PIPE import PyPDF2 as pypdf -from decimal import Decimal +from decimal import Decimal, getcontext FRIENDLY_COLORSPACE = { @@ -110,4 +110,5 @@ def _pdf_get_pageinfo(infile, page: int): def pdf_get_all_pageinfo(infile): pdf = pypdf.PdfFileReader(infile) + getcontext().prec = 6 return [_pdf_get_pageinfo(infile, n) for n in range(pdf.numPages)]