I figured it out, just needed a couple of tweaks. Originally, the output doc was created using activePDF. We’re replacing it everywhere with Aspose.
var firstPdf = new Document("Document1.pdf");
var secondPdf = new Document("Document2.pdf");
var originalPageCount = firstPdf.Pages.Count;
firstPdf.Pages.Add(secondPdf.Pages);
var parentOutline = new OutlineItemCollection(firstPdf.Outlines)
{
Title = "Title",
Action = new GoToAction(firstPdf.Pages[originalPageCount + 1])
};
var bookmarkEditor = new PdfBookmarkEditor(secondPdf);
foreach (var bookmark in bookmarkEditor.ExtractBookmarks())
{
var childOutline = new OutlineItemCollection(firstPdf.Outlines)
{
Title = bookmark.Title,
Action = new GoToAction(firstPdf.Pages[originalPageCount + bookmark.PageNumber])
};
parentOutline.Add(childOutline);
}
firstPdf.Outlines.Add(parentOutline);
firstPdf.Save("Merged.pdf");