Adjust for pikepdf API change
This commit is contained in:
@@ -248,7 +248,7 @@ setup(
|
|||||||
install_requires=[
|
install_requires=[
|
||||||
'cffi >= 1.9.1', # must be a setup and install requirement
|
'cffi >= 1.9.1', # must be a setup and install requirement
|
||||||
'img2pdf >= 0.2.4', # pure Python, so track HEAD closely
|
'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.0.0, != 5.1.0 ; sys_platform == "darwin"',
|
||||||
# Pillow < 4 has BytesIO/TIFF bug w/img2pdf 0.2.3
|
# Pillow < 4 has BytesIO/TIFF bug w/img2pdf 0.2.3
|
||||||
# block 5.1.0, broken wheels
|
# block 5.1.0, broken wheels
|
||||||
|
|||||||
@@ -71,11 +71,11 @@ def _weave_layers_graft(
|
|||||||
# content may have a rotation applied. Wrap the text stream with a rotation
|
# 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.
|
# 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.)
|
# (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)]
|
for v in range(4)]
|
||||||
wt, ht = mediabox[2] - mediabox[0], mediabox[3] - mediabox[1]
|
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)]
|
for v in range(4)]
|
||||||
wp, hp = mediabox[2] - mediabox[0], mediabox[3] - mediabox[1]
|
wp, hp = mediabox[2] - mediabox[0], mediabox[3] - mediabox[1]
|
||||||
|
|
||||||
|
|||||||
@@ -583,13 +583,13 @@ def _pdf_get_pageinfo(pdf, pageno: int, infile):
|
|||||||
else:
|
else:
|
||||||
pageinfo['has_text'] = _naive_find_text(pdf=pdf, page=page)
|
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]
|
width_pt = mediabox[2] - mediabox[0]
|
||||||
height_pt = mediabox[3] - mediabox[1]
|
height_pt = mediabox[3] - mediabox[1]
|
||||||
|
|
||||||
userunit = page.get('/UserUnit', Decimal(1.0))
|
userunit = page.get('/UserUnit', Decimal(1.0))
|
||||||
if not isinstance(userunit, Decimal):
|
if not isinstance(userunit, Decimal):
|
||||||
userunit = userunit.decode()
|
userunit = Decimal(userunit)
|
||||||
pageinfo['userunit'] = userunit
|
pageinfo['userunit'] = userunit
|
||||||
pageinfo['width_inches'] = width_pt * userunit / Decimal(72.0)
|
pageinfo['width_inches'] = width_pt * userunit / Decimal(72.0)
|
||||||
pageinfo['height_inches'] = height_pt * userunit / Decimal(72.0)
|
pageinfo['height_inches'] = height_pt * userunit / Decimal(72.0)
|
||||||
|
|||||||
Reference in New Issue
Block a user