diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b8ea77e..0dcc00c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file. The format - 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)) - Dereference structure element attributes (h/t @dhdaines). ([#1169](https://github.com/jsvine/pdfplumber/pull/1169)) +- Fix `Page.get_attr(...)` so that it fully resolves references before determining whether the attribute's value is `None` (h/t @zzhangyun + @mkl). ([#1176](https://github.com/jsvine/pdfplumber/issues/1176)) ## [0.11.2] - 2024-07-06 diff --git a/pdfplumber/page.py b/pdfplumber/page.py index 3718829f..296e39e1 100644 --- a/pdfplumber/page.py +++ b/pdfplumber/page.py @@ -216,8 +216,8 @@ def __init__( self.initial_doctop = initial_doctop def get_attr(key: str, default: Any = None) -> Any: - ref = page_obj.attrs.get(key) - return default if ref is None else resolve_all(ref) + value = resolve_all(page_obj.attrs.get(key)) + return default if value is None else value # Per PDF Reference Table 3.27: "The number of degrees by which the # page should be rotated clockwise when displayed or printed. The value