Hi.
I am attempting to create bookmark for several blocks on several pages, to create a Table of Content. Each page can contain more than one block. When reading your documents I have found this:
Location location = new Location();
location.Page = document.Pages.Last(); // The issue
location.Left = 10;
location.Top = 10;
BookmarkItem bookmark = new BookmarkItem(titleString, location);
bookmark.IsExpanded = true;
document.Bookmarks.Add(bookmark);
This works creating a ToC with the help of this method:
private static void ToC()
{
RadFixedPage toc = new RadFixedPage();
document.Pages.Insert(1, toc);
FixedContentEditor editor = new FixedContentEditor(toc);
int offSetVal = 0;
foreach (BookmarkItem bookmark in document.Bookmarks)
{
int pageNumber = 1;
if (pageNumber > 0)
{
int factor = 20;
int offsetX = 70;
int offsetY = offSetVal + 20 + factor * pageNumber;
offSetVal += 10;
editor.Position.Translate(offsetX, offsetY);
Block block = new Block();
block.InsertLineBreak();
block.GraphicProperties.FillColor = new RgbColor(255, 5, 99, 193);
block.InsertText(bookmark.Title);
Size blockSize = block.Measure();
editor.DrawBlock(block);
var location = bookmark.Destination;
GoToAction goToAction = new GoToAction();
goToAction.Destination = location;
Link uriLink = toc.Annotations.AddLink(goToAction);
uriLink.Rect = new Rect(offsetX, offsetY, blockSize.Width, blockSize.Height);
}
}
}
The problem is that each action links to the same page. When debugging I can also see that "document.Pages.Last()" has the same value. How can I make it so the correct page is connected?
PS: Please let me know if any value is needed.
Thanks
-Steffen