OutlineCollection Add Same OutlineItemCollection

I tried to add the same OutlineItemCollection to pdf Outline, but only one of data is finally displayed in Outline. Why does this happen? The meetingPdf.Pages.Count in actual using will be different.

Aspose.Pdf.Document meetingPdf = new Aspose.Pdf.Document();

OutlineItemCollection outline1 = new OutlineItemCollection(meetingPdf.Outlines)
{
    Title = "test1",
    Action = new GoToAction(meetingPdf.Pages[meetingPdf.Pages.Count])
};
OutlineItemCollection outline2 = new OutlineItemCollection(meetingPdf.Outlines)
{
    Title = "test1",
    Action = new GoToAction(meetingPdf.Pages[meetingPdf.Pages.Count])
};

//add same OutlineItemCollection 
meetingPdf.Outlines.Add(outline1);
meetingPdf.Outlines.Add(outline2);

I tried to emulate your problem on version 24.2 following code shows that meetingPdf.Outlines contains 3 entries
Do I understand correctly that in your case you see only 1 entry in Outlines?

Aspose.Pdf.Document meetingPdf = new Aspose.Pdf.Document();
meetingPdf.Pages.Add();
OutlineItemCollection outline1 = new OutlineItemCollection(meetingPdf.Outlines)
{
    Title = "test1",
    Action = new GoToAction(meetingPdf.Pages[meetingPdf.Pages.Count])
};
OutlineItemCollection outline2 = new OutlineItemCollection(meetingPdf.Outlines)
{
    Title = "test1",
    Action = new GoToAction(meetingPdf.Pages[meetingPdf.Pages.Count])
};

//add same OutlineItemCollection 
meetingPdf.Outlines.Add(outline1);
meetingPdf.Outlines.Add(outline2);

Yes, my expectation was that there would be multiple duplicates of information presented.

And I have a question about whether this method will perform special processing on multiple repeated information, causing problems in the final presentation?

Or is this part a limitation of the PDF itself?

Could you please share details about what version of Aspose.PDF you are using ?
I tried your code snippet and it seems that it working just fine in current version and both duplicates can be seen in outline collection in final version of pdf document
outline_collection_24_2.png (12.4 KB)
Outline.pdf (85.9 KB)

The version I am using is 19.1.0

In that case I suggest you to update to version 24.2 and see if issue with outlines remains present

Okay, I will test this part after the version is upgraded. Thank you for your help.

1 Like