Skip to content

Commit

Permalink
fix normal links
Browse files Browse the repository at this point in the history
  • Loading branch information
iammosespaulr committed Jan 17, 2025
1 parent fee11e4 commit 1feddb2
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions pdftext/pdf/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,18 @@ def merge_links(page: Page, pdf: pdfium.PdfDocument, refs: PageReference):
span = spans[max_intersection]

dest_page = link['dest_page']
if dest_page is None:
continue

if link['dest_pos']:
dest_pos = link['dest_pos']
else:
# Don't link to self if there is no dest_pos
if dest_page == page_id:
continue
# if we don't have a dest pos, we just link to the top of the page
dest_pos = [0.0, 0.0]

ref = refs.add_ref(dest_page, dest_pos)
link['url'] = ref.url
if dest_page is not None:
if link['dest_pos']:
dest_pos = link['dest_pos']
else:
# Don't link to self if there is no dest_pos
if dest_page == page_id:
continue
# if we don't have a dest pos, we just link to the top of the page
dest_pos = [0.0, 0.0]

ref = refs.add_ref(dest_page, dest_pos)
link['url'] = ref.url

span_link_map.setdefault(max_intersection, [])
span_link_map[max_intersection].append(link)
Expand Down

0 comments on commit 1feddb2

Please sign in to comment.