Skip to content

Commit 00fb53d

Browse files
wolfram77Lucas-C
andcommitted
Update pdfly/extract_annotated_pages.py
Seems that the `| None` syntax is not valid with Python 3.8 Co-authored-by: Lucas Cimon <[email protected]>
1 parent 1e0ecdd commit 00fb53d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pdfly/extract_annotated_pages.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,27 @@
66
"""
77

88
from pathlib import Path
9+
from typing import Optional
10+
911
from pypdf import PdfReader, PdfWriter
12+
from pypdf.annotations import AnnotationDictionary
1013

1114

1215
# Check if an annotation is manipulable.
13-
def is_manipulable(annot) -> bool:
16+
def is_manipulable(annot: AnnotationDictionary) -> bool:
1417
return annot.get("/Subtype") not in ["/Link"]
1518

1619

1720
# Main function.
18-
def main(input_pdf: Path, output_pdf: Path) -> None:
21+
def main(input_pdf: Path, output_pdf: Optional[Path]) -> None:
1922
if not output_pdf:
2023
output_pdf = input_pdf.with_stem(input_pdf.stem + "_annotated")
2124
input = PdfReader(input_pdf)
2225
output = PdfWriter()
2326
output_pages = 0
2427
# Copy only the pages with annotations
2528
for page in input.pages:
26-
if not "/Annots" in page:
29+
if "/Annots" not in page:
2730
continue
2831
if not any(is_manipulable(annot) for annot in page["/Annots"]):
2932
continue

0 commit comments

Comments
 (0)