PrintDocument for WinForms | ComponentOne
PrintDocument Library / Outline
In This Topic
    Outline
    In This Topic

    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:

    Snapshot of outlines in application.

    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.

    1. From the Toolbox, add the C1PrintPreviewControl and C1PrintDocument controls to your project.
    2. Click C1PrintPreviewControl1 to select it and in the Properties window set its Document property to C1PrintDocument1.
    3. Add the following code to the Form_Load event:
      C#
      Copy Code
      private void Form1_Load(object sender, EventArgs e)
      {
          // Make the document.   
          MakeDoc();
          // Generate the document.   
          this.c1PrintDocument1.Generate();
      }
      
    4. Add the MakeDoc subroutine, which uses the OutlineNodeCollection.Add method to add outline entries to the Outline tab:
      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);
       }