Skip to content

Commit

Permalink
STY: Rename local annotation variables (#2984)
Browse files Browse the repository at this point in the history
Make the names of annotation variables more consistent and readable.
  • Loading branch information
j-t-1 authored Dec 3, 2024
1 parent b4af495 commit ae93e98
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions pypdf/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,21 +1162,20 @@ def reattach_fields(

if "/Annots" not in page:
return lst
annots = cast(ArrayObject, page["/Annots"])
for idx in range(len(annots)):
ano = annots[idx]
indirect = isinstance(ano, IndirectObject)
ano = cast(DictionaryObject, ano.get_object())
if ano.get("/Subtype", "") == "/Widget" and "/FT" in ano:
annotations = cast(ArrayObject, page["/Annots"])
for idx, annotation in enumerate(annotations):
is_indirect = isinstance(annotation, IndirectObject)
annotation = cast(DictionaryObject, annotation.get_object())
if annotation.get("/Subtype", "") == "/Widget" and "/FT" in annotation:
if (
"indirect_reference" in ano.__dict__
and ano.indirect_reference in fields
"indirect_reference" in annotation.__dict__
and annotation.indirect_reference in fields
):
continue
if not indirect:
annots[idx] = self._add_object(ano)
fields.append(ano.indirect_reference)
lst.append(ano)
if not is_indirect:
annotations[idx] = self._add_object(annotation)
fields.append(annotation.indirect_reference)
lst.append(annotation)
return lst

def clone_reader_document_root(self, reader: PdfReader) -> None:
Expand Down

0 comments on commit ae93e98

Please sign in to comment.