@@ -1502,13 +1502,12 @@ def _write_increment(self, stream: StreamType) -> None:
15021502
15031503 def _write_pdf_structure (self , stream : StreamType ) -> Tuple [List [int ], List [int ]]:
15041504 object_positions = []
1505- free_objects = [] # will contain list of all free entries
1505+ free_objects = []
15061506 stream .write (self .pdf_header .encode () + b"\n " )
15071507 stream .write (b"%\xE2 \xE3 \xCF \xD3 \n " )
15081508
1509- for i , obj in enumerate (self ._objects ):
1509+ for idnum , obj in enumerate (self ._objects , start = 1 ):
15101510 if obj is not None :
1511- idnum = i + 1
15121511 object_positions .append (stream .tell ())
15131512 stream .write (f"{ idnum } 0 obj\n " .encode ())
15141513 if self ._encryption and obj != self ._encrypt_entry :
@@ -1517,8 +1516,8 @@ def _write_pdf_structure(self, stream: StreamType) -> Tuple[List[int], List[int]
15171516 stream .write (b"\n endobj\n " )
15181517 else :
15191518 object_positions .append (- 1 )
1520- free_objects .append (i + 1 )
1521- free_objects .append (0 ) # add 0 to loop in accordance with PDF spec
1519+ free_objects .append (idnum )
1520+ free_objects .append (0 ) # add 0 to loop in accordance with specification
15221521 return object_positions , free_objects
15231522
15241523 def _write_xref_table (
@@ -1760,7 +1759,7 @@ def get_reference(self, obj: PdfObject) -> IndirectObject:
17601759
17611760 def get_outline_root (self ) -> TreeObject :
17621761 if CO .OUTLINES in self ._root_object :
1763- # Table 3.25 Entries in the catalog dictionary
1762+ # Entries in the catalog dictionary
17641763 outline = cast (TreeObject , self ._root_object [CO .OUTLINES ])
17651764 if not isinstance (outline , TreeObject ):
17661765 t = TreeObject (outline )
@@ -1784,12 +1783,12 @@ def get_threads_root(self) -> ArrayObject:
17841783 See §12.4.3 of the PDF 1.7 or PDF 2.0 specification.
17851784
17861785 Returns:
1787- An array (possibly empty) of Dictionaries with ``/F`` and
1788- ``/I`` properties .
1786+ An array (possibly empty) of Dictionaries with an ``/F`` key,
1787+ and optionally information about the thread in ``/I`` or ``/Metadata`` keys .
17891788
17901789 """
17911790 if CO .THREADS in self ._root_object :
1792- # Table 3.25 Entries in the catalog dictionary
1791+ # Entries in the catalog dictionary
17931792 threads = cast (ArrayObject , self ._root_object [CO .THREADS ])
17941793 else :
17951794 threads = ArrayObject ()
@@ -1801,9 +1800,10 @@ def threads(self) -> ArrayObject:
18011800 """
18021801 Read-only property for the list of threads.
18031802
1804- See §8.3.2 from PDF 1.7 spec .
1803+ See §12.4.3 of the PDF 1.7 or PDF 2.0 specification .
18051804
1806- Each element is a dictionary with ``/F`` and ``/I`` keys.
1805+ Each element is a dictionary with an ``/F`` key, and optionally
1806+ information about the thread in ``/I`` or ``/Metadata`` keys.
18071807 """
18081808 return self .get_threads_root ()
18091809
0 commit comments