Skip to content

Commit b16acc3

Browse files
committed
Fix coords for annotations on CroppedPages
1 parent 1496cbd commit b16acc3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file. The format
1616
### Fixed
1717

1818
- Fix error on getting `.annots`/`.hyperlinks` from `CroppedPage` (due to missing `.rotation` and `.initial_doctop` attributes) (h/t @Safrone). ([#1171](https://github.com/jsvine/pdfplumber/issues/1171) + [e5737d2](https://github.com/jsvine/pdfplumber/commit/e5737d2))
19+
- Fix calculation of coordinates for `.annots` on `CroppedPage`s. ([0bbb340](https://github.com/jsvine/pdfplumber/commit/0bbb340))
1920
- Dereference structure element attributes (h/t @dhdaines). ([#1169](https://github.com/jsvine/pdfplumber/pull/1169))
2021
- Fix `Page.get_attr(...)` so that it fully resolves references before determining whether the attribute's value is `None` (h/t @zzhangyun + @mkl-public). ([#1176](https://github.com/jsvine/pdfplumber/issues/1176))
2122

pdfplumber/page.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ def parse(annot: T_obj) -> T_obj:
291291
_a, _b, _c, _d = annot["Rect"]
292292
pt0 = rotate_point((_a, _b), self.rotation)
293293
pt1 = rotate_point((_c, _d), self.rotation)
294-
x0, top, x1, bottom = _invert_box(_normalize_box((*pt0, *pt1)), self.height)
294+
rh = self.root_page.height
295+
x0, top, x1, bottom = _invert_box(_normalize_box((*pt0, *pt1)), rh)
295296

296297
a = annot.get("A", {})
297298
extras = {
@@ -310,9 +311,9 @@ def parse(annot: T_obj) -> T_obj:
310311
"page_number": self.page_number,
311312
"object_type": "annot",
312313
"x0": x0,
313-
"y0": self.height - bottom,
314+
"y0": rh - bottom,
314315
"x1": x1,
315-
"y1": self.height - top,
316+
"y1": rh - top,
316317
"doctop": self.initial_doctop + top,
317318
"top": top,
318319
"bottom": bottom,

0 commit comments

Comments
 (0)