PrintDocument enables you to open documents and display bookmarks or outlines via a bookmarks panel. The outline items allow users, by interacting with them, to navigate across different parts of the document. The document outline is a tree (specified by the Outlines property), with nodes (of the type OutlineNode) pointing to locations in the document. The outline is shown on a tab in the navigation panel of the preview, and allows navigating to locations corresponding to items by clicking on the items. Also, outlines are exported to formats supporting that notion (such as PDF).
The GIF below depicts the outline nodes "RenderText1" and "RenderText2" in the Outline tab:
To create an outline node, use any of the overloaded Outline constructors. You can specify the text of the outline, the location within the document (a render object or an anchor), and an icon to be shown in the outline tree panel in the preview. Top-level nodes should be added to the Outlines collection of the document. Each outline node may, in its turn, contain a collection of child nodes in the Children collection, and so on.
To add outline nodes or entries to the Outline tab, use the OutlineNodeCollection.Add method.
C# |
Copy Code
|
---|---|
private void Form1_Load(object sender, EventArgs e) { // Make the document. MakeDoc(); // Generate the document. this.c1PrintDocument1.Generate(); } |
C# |
Copy Code
|
---|---|
private void MakeDoc() { // Create RenderText1. C1.C1Preview.RenderText rt1 = new C1.C1Preview.RenderText(); rt1.Text = "This is RenderText1."; // Add an outline entry point for RenderText1. this.c1PrintDocument1.Outlines.Add("RenderText1", rt1); // Add a page break. rt1.BreakAfter = C1.C1Preview.BreakEnum.Page; // Create RenderText2. C1.C1Preview.RenderText rt2 = new C1.C1Preview.RenderText(); rt2.Text = "This is RenderText2."; // Add an outline entry point for RenderText2. this.c1PrintDocument1.Outlines.Add("RenderText2", rt2); // Add the RenderText to the document. this.c1PrintDocument1.Body.Children.Add(rt1); this.c1PrintDocument1.Body.Children.Add(rt2); } |