Remove shims to support for old versions of pikepdf < 4
This commit is contained in:
+1
-10
@@ -58,8 +58,6 @@ def strip_invisible_text(pdf, page):
|
||||
render_mode = 0
|
||||
text_objects = []
|
||||
|
||||
rich_page = Page(page)
|
||||
rich_page.contents_coalesce()
|
||||
for operands, operator in parse_content_stream(page, ''):
|
||||
if not in_text_obj:
|
||||
if operator == Operator('BT'):
|
||||
@@ -303,14 +301,7 @@ class OcrGrafter:
|
||||
if strip_old_text:
|
||||
strip_invisible_text(self.pdf_base, base_page)
|
||||
|
||||
if hasattr(Page, 'contents_add'):
|
||||
# pikepdf >= 2.14 adds this method and deprecates the one below
|
||||
Page(base_page).contents_add(new_text_layer, prepend=True)
|
||||
else:
|
||||
# pikepdf < 2.14
|
||||
base_page.page_contents_add(
|
||||
new_text_layer, prepend=True
|
||||
) # pragma: no cover
|
||||
base_page.contents_add(new_text_layer, prepend=True)
|
||||
|
||||
_update_resources(
|
||||
obj=base_page, font=font, font_key=font_key, procset=procset
|
||||
|
||||
@@ -557,10 +557,6 @@ def test_skip_big_with_no_images(resources, outpdf):
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
'8.0.0' <= pikepdf.__libqpdf_version__ <= '8.0.1',
|
||||
reason="libqpdf regression on pages with no contents",
|
||||
)
|
||||
def test_no_contents(resources, outpdf):
|
||||
check_ocrmypdf(
|
||||
resources / 'no_contents.pdf',
|
||||
|
||||
@@ -302,9 +302,6 @@ def test_kodak_toc(resources, outpdf):
|
||||
assert isinstance(p.Root.Outlines.First, pikepdf.Dictionary)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
pikepdf.__version__ in ('2.2.2', '2.2.3'), reason="Raises wrong warning"
|
||||
)
|
||||
def test_metadata_fixup_warning(resources, outdir, caplog):
|
||||
options = get_parser().parse_args(
|
||||
args=['--output-type', 'pdfa-2', 'graph.pdf', 'out.pdf']
|
||||
|
||||
@@ -205,11 +205,11 @@ def test_pages_issue700(monkeypatch, resources):
|
||||
|
||||
def test_image_scale0(resources, outpdf):
|
||||
with pikepdf.open(resources / 'cmyk.pdf') as cmyk:
|
||||
xobj = pikepdf.Page(cmyk.pages[0]).as_form_xobject()
|
||||
xobj = cmyk.pages[0].as_form_xobject()
|
||||
|
||||
p = pikepdf.Pdf.new()
|
||||
p.add_blank_page(page_size=(72, 72))
|
||||
objname = pikepdf.Page(p.pages[0]).add_resource(
|
||||
objname = p.pages[0].add_resource(
|
||||
p.copy_foreign(xobj), pikepdf.Name.XObject, pikepdf.Name.Im0
|
||||
)
|
||||
print(objname)
|
||||
|
||||
Reference in New Issue
Block a user