Skip to content

Commit

Permalink
Fix Page.links generator
Browse files Browse the repository at this point in the history
  • Loading branch information
niallcm authored and julian-smith-artifex-com committed Jan 22, 2024
1 parent 5b9e2f1 commit 77bbc8c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9156,7 +9156,7 @@ def links(self, kinds=None):
all links are returned. E.g. kinds=[LINK_URI]
will only yield URI links.
"""
all_links = self.getLinks()
all_links = self.get_links()
for link in all_links:
if kinds is None or link["kind"] in kinds:
yield (link)
Expand Down
17 changes: 17 additions & 0 deletions tests/test_page_links.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import fitz

import os


def test_page_links_generator():
# open some arbitrary PDF
path = os.path.abspath(f"{__file__}/../../tests/resources/2.pdf")
doc = fitz.open(path)

# select an arbitrary page
page = doc[-1]

# iterate over pages.links
link_generator = page.links()
links = list(link_generator)
assert len(links) == 7

0 comments on commit 77bbc8c

Please sign in to comment.