Skip to content

Commit

Permalink
fix: use PLAYA 0.3.1 which fixes bad bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
dhdaines committed Feb 28, 2025
1 parent 598f095 commit d9ee454
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions pdfannots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _mkannotation(
def _get_outlines(doc: PDFDocument) -> typ.Iterator[Outline]:
"""Retrieve a list of (unresolved) Outline objects for all recognised outlines in the PDF."""

# TODO: use PLAYA 0.3 Destinations API
# TODO: use PLAYA 0.3 Destinations API or move get_dests to PAVÉS
dests = {k: v for k, v in doc.dests}

def _resolve_dest(dest: typ.Any) -> typ.Any:
Expand All @@ -130,6 +130,7 @@ def _resolve_dest(dest: typ.Any) -> typ.Any:
dest = dest['D']
return dest

# TODO: use PLAYA 0.3 Outline API or move outlines to PAVÉS
for (_, title, destname, actionref, _) in doc.outlines:
if destname is None and actionref:
action = pdftypes.resolve1(actionref)
Expand Down Expand Up @@ -398,15 +399,12 @@ def emit_progress(msg: str) -> None:

# Iterate over all the pages, constructing page objects.
result = Document()
# PLAYA will make up page labels if they don't exist (this is
# arguably a bug in PLAYA) so use the explicit ones only.
try:
page_labels = doc.page_labels
except (KeyError, ValueError):
page_labels = itertools.repeat(None)
for pdfpage, page_label in zip(doc.pages, page_labels):
for pdfpage in doc.pages:
pageno = pdfpage.page_idx
emit_progress(" %d" % (pageno + 1))
# PLAYA will make up page labels if they don't exist (this is
# arguably a bug in PLAYA) so use the explicit ones only.
page_label = pdfpage.label if doc.pages.have_labels else None

page = Page(pageno, pdfpage.pageid, page_label, pdfpage.mediabox, columns_per_page)
result.pages.append(page)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "hatchling.build"
name = "pdfannots"
dynamic = ["version"]
requires-python = ">=3.8"
dependencies = ["paves", "playa-pdf>=0.3.0"]
dependencies = ["paves", "playa-pdf>=0.3.1"]
description = "Tool to extract and pretty-print PDF annotations for reviewing"
readme = "README.md"
license = {file = "LICENSE.txt"}
Expand Down

0 comments on commit d9ee454

Please sign in to comment.