@cian.hartigan,
You are right, while coding the solution I got sidetracked and thought it was about a TOC.
Here is the same code but I added the bookmarks. Keep in mind I tested the output in the Google Chrome and the bookmarks work fine.
private void Logic()
{
Document doc = new Document();
Document doc1 = new Document($"{PartialPath}_input_1.pdf");
Document doc2 = new Document($"{PartialPath}_input_2.pdf");
Document doc3 = new Document($"{PartialPath}_input_rotated.pdf");
Document doc4 = new Document($"{PartialPath}_input_3.pdf");
var docList = new List<Document> { doc1, doc2, doc3, doc4 };
Page tocPage = doc.Pages.Add();
tocPage.TocInfo = new TocInfo();
int countDoc = 0;
int countPage = 0;
doc.Outlines.Clear();
foreach (var docToMerge in docList)
{
countDoc++;
foreach (var pageToAdd in docToMerge.Pages)
{
countPage++;
var page = doc.Pages.Add(pageToAdd);
if (countDoc == 3)
{
page.Rotate = Rotation.on180;
}
page.AddStamp(new PageNumberStamp());
string textTitle = $"Doc: {countDoc} - page: {countPage}";
tocPage.Paragraphs.Add(new Heading(1)
{
TocPage = tocPage,
DestinationPage = page,
Text = textTitle,
Margin = new MarginInfo(0, 20, 0, 20)
});
OutlineItemCollection pdfOutline = new OutlineItemCollection(doc.Outlines);
pdfOutline.Title = textTitle;
pdfOutline.Destination = new GoToAction(page);
doc.Outlines.Add(pdfOutline);
}
}
doc.Save($"{PartialPath}_output.pdf");
}
The output file:
BookmarkGoesToWrongPageInChrome_output.pdf (112.1 KB)