diff --git a/docs/user/reading-pdf-annotations.md b/docs/user/reading-pdf-annotations.md index 8c01fe728..fc87377d3 100644 --- a/docs/user/reading-pdf-annotations.md +++ b/docs/user/reading-pdf-annotations.md @@ -16,6 +16,21 @@ PDF 1.7 defines 25 different annotation types: * Watermark * 3D +In general, annotations can be read like this: + +```python +from PyPDF2 import PdfReader + +reader = PdfReader("commented.pdf") + +for page in reader.pages: + if "/Annots" in page: + for annot in page["/Annots"]: + obj = annot.get_object() + annotation = {"subtype": obj["/Subtype"], "location": obj["/Rect"]} + print(annotation) +``` + Reading the most common ones is described here. ## Text diff --git a/tests/test_filters.py b/tests/test_filters.py index e34c5e05f..32dd5e642 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -103,7 +103,7 @@ def test_ASCIIHexDecode(data, expected): """ Feeds a bunch of values to ASCIIHexDecode.decode() and ensures the correct output is returned. - TO-DO What is decode() supposed to do for such inputs as ">>", ">>>" or + TODO What is decode() supposed to do for such inputs as ">>", ">>>" or any other not terminated by ">"? (For the latter case, an exception is currently raised.) """