Skip to content

Commit 3d84ba8

Browse files
STY: File identifier generation restructuring
#2003 Co-authored-by: exiledkingcc <exiledkingcc@gmail.com>
1 parent beca111 commit 3d84ba8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pypdf/_writer.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ def cloneDocumentFromReader(
12231223
)
12241224
self.clone_document_from_reader(reader, after_page_append)
12251225

1226-
def _compute_document_identifier_from_content(self) -> ByteStringObject:
1226+
def _compute_document_identifier(self) -> ByteStringObject:
12271227
stream = BytesIO()
12281228
self._write_pdf_structure(stream)
12291229
stream.seek(0)
@@ -1238,9 +1238,10 @@ def generate_file_identifiers(self) -> None:
12381238
"""
12391239
if self._ID:
12401240
id1 = self._ID[0]
1241+
id2 = self._compute_document_identifier()
12411242
else:
1242-
id1 = self._compute_document_identifier_from_content()
1243-
id2 = self._compute_document_identifier_from_content()
1243+
id1 = self._compute_document_identifier()
1244+
id2 = id1
12441245
self._ID = ArrayObject((id1, id2))
12451246

12461247
def encrypt(

0 commit comments

Comments
 (0)