Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10670,8 +10670,10 @@ def annots(self, types=None):
annot_xrefs = [a[0] for a in self.annot_xrefs() if a[1] in types and a[1] not in skip_types]
for xref in annot_xrefs:
annot = self.load_annot(xref)
annot._yielded=True
yield annot
# In #4928, annot can be None, which we need to ignore.
if annot:
annot._yielded=True
yield annot

def apply_redactions(
page: 'Page',
Expand Down
Binary file added tests/resources/test_4944.pdf
Binary file not shown.
21 changes: 21 additions & 0 deletions tests/test_annots.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,3 +718,24 @@ def draw_rectangle(rect, c, w):
document.save(path_out)
print(f' {path=}.')
print(f'{path_out=}.')


def test_4944():
path = os.path.normpath(f'{__file__}/../../tests/resources/test_4944.pdf')
path_out = os.path.normpath(f'{__file__}/../../tests/test_4944_out.pdf')
print()
with pymupdf.open(path) as document:
page = document[0]
print(f'{page.rotation=}')
print(f'{page.rotation_matrix=}')
print(f'{page.transformation_matrix=}')
text_json = page.get_text('rawjson')
#print(text_json)

page.add_redact_annot(page.rect)
page.apply_redactions(text=pymupdf.PDF_REDACT_TEXT_REMOVE)
document.save(path_out)
print(repr(page.get_text()))

text_json = page.get_text('rawjson')
#print(text_json)
7 changes: 3 additions & 4 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -2213,13 +2213,12 @@ def test_4907():
display_list = page.get_displaylist(annots=False)
text_page = display_list.get_textpage()


def test_4928():
path = os.path.normpath(f'{__file__}/../../tests/resources/test_4928.pdf')
with pymupdf.open(path) as document:
try:
document.scrub()
except Exception as e:
print(f'Ignoring expected exception: {e}')
document.scrub()


def test_4902():
print()
Expand Down
Loading