Collapsing outlines not working: parameter is_open in add_outline_item has no effect #2994
Labels
PdfWriter
The PdfWriter component is affected
workflow-annotation
Everything about annotating PDF files
I tried adding a (nested) outline to a document, and I wanted it to be collapsed by default when opening the file. So I set
is_open
to False inwriter.add_outline_item
, but the outlines are still all expanded.I looked a bit into the code, and from my understanding the problem lies in
writer.add_outline_destination
when callingparent.insert_child
:When giving the
inc_parent_counter
, a defaultinc_parent_counter_outline
is passed ifis_open == True
, and some lambda returning 0 at all times otherwise. However it seems to be exactly theinc_parent_counter_outline
that handles setting "/Count" to -1 if the outlines should be collapsed. So I removed the if statement (so it always passesinc_parent_counter_outline
), and now my outlines are collapsed. So this seems to fix it, however I have no idea whether that breaks anything else that doesn't affect my usecase.In case it helps:
Change
to
Environment
python 3.10.12 in WSL
Code + PDF
This is a minimal (I hope), complete example that shows the issue:
Any PDF should produce this issue, however I append a random minimal pdf that does produce the issue: test.pdf
Traceback
There is no traceback.
The text was updated successfully, but these errors were encountered: