Adjust for pikepdf API change

This commit is contained in:
James R. Barlow
2018-06-08 22:47:56 -07:00
parent 740918daee
commit 1dfbbdebf4
3 changed files with 5 additions and 5 deletions

View File

@@ -248,7 +248,7 @@ setup(
install_requires=[
'cffi >= 1.9.1', # must be a setup and install requirement
'img2pdf >= 0.2.4', # pure Python, so track HEAD closely
'pikepdf',
'pikepdf >= 0.2.0',
'Pillow >= 4.0.0, != 5.1.0 ; sys_platform == "darwin"',
# Pillow < 4 has BytesIO/TIFF bug w/img2pdf 0.2.3
# block 5.1.0, broken wheels

View File

@@ -71,11 +71,11 @@ def _weave_layers_graft(
# content may have a rotation applied. Wrap the text stream with a rotation
# so it will be oriented the same way as the rest of the page content.
# (Previous versions OCRmyPDF rotated the content layer to match the text.)
mediabox = [float(pdf_text.pages[0].MediaBox[v].decode())
mediabox = [float(pdf_text.pages[0].MediaBox[v])
for v in range(4)]
wt, ht = mediabox[2] - mediabox[0], mediabox[3] - mediabox[1]
mediabox = [float(base_page.MediaBox[v].decode())
mediabox = [float(base_page.MediaBox[v])
for v in range(4)]
wp, hp = mediabox[2] - mediabox[0], mediabox[3] - mediabox[1]

View File

@@ -583,13 +583,13 @@ def _pdf_get_pageinfo(pdf, pageno: int, infile):
else:
pageinfo['has_text'] = _naive_find_text(pdf=pdf, page=page)
mediabox = [Decimal(d.decode()) for d in page.MediaBox.as_list()]
mediabox = [Decimal(d) for d in page.MediaBox.as_list()]
width_pt = mediabox[2] - mediabox[0]
height_pt = mediabox[3] - mediabox[1]
userunit = page.get('/UserUnit', Decimal(1.0))
if not isinstance(userunit, Decimal):
userunit = userunit.decode()
userunit = Decimal(userunit)
pageinfo['userunit'] = userunit
pageinfo['width_inches'] = width_pt * userunit / Decimal(72.0)
pageinfo['height_inches'] = height_pt * userunit / Decimal(72.0)