itext-java icon indicating copy to clipboard operation
itext-java copied to clipboard

Fix bug: dont remove parent just because children is empty

Open kpldvnpne opened this issue 5 months ago • 0 comments

Reason:

Currently there is a bug with PdfOutline.removeOutline function. Here is what happens in this bug:

If there is an outline like this:

Parent Outline
|- Child Outline

and, we remove Child Outline, then the parent outline automatically gets removed because the parent now has no children.

This is the relevant part of the code:

if (children.size() > 0) {
    parentContent.put(PdfName.First, children.get(0).content);
    parentContent.put(PdfName.Last, children.get(children.size() - 1).content);
} else {
    parent.removeOutline();
    return;
}

Hence, in this PR, I removed the line parent.removeOutline(); so that the parent does not get removed.

kpldvnpne avatar Jun 03 '25 23:06 kpldvnpne