-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
Explanation
When retrieving outlines via PdfReader method _get_outlines(), the "/Count" attribute is ignored. The count is a required attribute for entries in an outline item dictionary with descendants. The count is the sum of the number of visible descendent outline items. If an outline is closed, the count is a negative number and the absolute value is the number of descendants that would be visible if the outline item were opened.
Code Example
An example of how this potentially could look once implemented:
from PyPDF2 import PdfReader
reader = PdfReader("example.pdf")
def show_tree(outlines, indent=0):
for item in outlines:
if isinstance(item, list):
show_tree(item, indent+4)
else:
print(f'{" "*indent}{item.title}, {item.count}')
show_tree(reader.outlines)First, 6
Second, None
Third, None
Fourth, 2
Fifth, None
Sixth, None
Seventh, -2
Eighth, None
Ninth, None
Tenth, 4
Eleventh, None
Twelfth, None
Thirteenth, None
Fourteenth, None
Fifteenth, -2
Sixteenth, None
Seventeenth, None
Eighteenth, None
Nineteenth, 8
Twentieth, None
Twenty-first, None
Twenty-second, None
Twenty-third, None
Twenty-fourth, None
Twenty-fifth, None
Twenty-sixth, None
Twenty-seventh, NoneReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels