Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Source/HtmlRenderer.PdfSharp/PdfGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ private static void HandleLinks(PdfDocument document, HtmlContainer container, X
{
// document links to the same page as the link is not allowed
int anchorPageIdx = (int)(anchorRect.Value.Top / pageSize.Height);

// in case that not find the page index, set to the first page.
if (anchorPageIdx == 0)
anchorPageIdx = 1;

if (i != anchorPageIdx)
document.Pages[i].AddDocumentLink(new PdfRectangle(xRect), anchorPageIdx);
}
Expand All @@ -233,4 +238,4 @@ private static void HandleLinks(PdfDocument document, HtmlContainer container, X

#endregion
}
}
}