I am trying to build a TOC using PdfSharp and while I can add the elements where I would like them, I can't get the document links to line up with the TOC elements like I expect they should. See the following code for an example:
Code:
PdfDocument doc = new PdfDocument();
PdfPage page = doc.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XRect rect = new XRect(5, 5, 500, 20);
PdfRectangle prect = new PdfRectangle(rect);
page.AddDocumentLink(prect, 1);
gfx.DrawRectangle(XBrushes.Transparent, rect);
doc.Save(@"C:\test.pdf");
With the code above I would place the text of my TOC element inside 'rect' and then clicking on that rectangle should link to the page of the document. However, the AddDocumentLink method is not placing that link at the same place on the page as the DrawRectangle is. It's placing it at the bottom. You can see the attached example document to see what is happening.
Thank you for any help with this,
Jon