private void CreateDocumentMap(Document document) { // Create a collection of 'Page and Brick' pairs. BrickPagePairCollection pairs = new BrickPagePairCollection(); // Create an enumerator of all document bricks. DocumentBrickEnumerator en = new DocumentBrickEnumerator(document); // Add the 'Brick-Page' pairs for all document bricks. while (en.MoveNext()) { pairs.Add(BrickPagePair.Create(en.Brick, en.Page)); } // Add bookmarks for all pairs to the document's map. foreach (BrickPagePair pair in pairs) { Page page = document.Pages[pair.PageIndex]; Brick brick = page.GetBrickByIndices(pair.BrickIndices) as Brick; string BrickText = ((TextBrick)brick).Text; BookmarkNode mapNode = new BookmarkNode(BrickText, brick, page); document.BookmarkNodes.Add(mapNode); } }
private static void CreateLinks(XtraReport report) { List <VisualBrick> linkBricks = new List <VisualBrick>(); List <VisualBrick> pageBricks = new List <VisualBrick>(); List <TargetBrick> targetBricks = new List <TargetBrick>(); foreach (Page page in report.Pages) { NestedBrickIterator iterator = new NestedBrickIterator(page.InnerBricks); while (iterator.MoveNext()) { VisualBrick brick = iterator.CurrentBrick as VisualBrick; if (brick != null && brick.Value != null) { string valueString = brick.Value.ToString(); if (valueString.StartsWith("Link_")) { linkBricks.Add(brick); } if (valueString.StartsWith("Target_")) { targetBricks.Add(new TargetBrick() { Brick = brick, Page = page }); } if (valueString.StartsWith("PageBrick_")) { pageBricks.Add(brick); } } } } foreach (VisualBrick link in linkBricks) { string key = link.Value.ToString().Substring(5); TargetBrick target = targetBricks.Find(targetBrick => (string)targetBrick.Brick.Value == String.Concat("Target_", key)); if (target != null) { target.Brick.AnchorName = key; link.Url = key; link.NavigationPair = BrickPagePair.Create(target.Brick, target.Page); VisualBrick pageBrick = pageBricks.Find(brick => (string)brick.Value == String.Concat("PageBrick_", key)); if (pageBrick != null) { pageBrick.Text = (target.Page.Index + 1).ToString(); } } } }