PrintDocument for WinForms
アウトライン
PrintDocument ライブラリ > アウトライン

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.

  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#
    コードのコピー
    private void Form1_Load(object sender, EventArgs e)
    {
        // ドキュメントを作成します。   
        MakeDoc();
        // ドキュメントを生成します。   
        this.c1PrintDocument1.Generate();
    }
    
  4. Add the MakeDoc subroutine, which uses the OutlineNodeCollection.Add method to add outline entries to the Outline tab:
    C#
    コードのコピー
    private void MakeDoc()
     {
         // RenderText1を作成します。   
         C1.C1Preview.RenderText rt1 = new C1.C1Preview.RenderText();
         rt1.Text = "This is RenderText1.";
         // RenderText1に対してアウトラインエントリの入力する点を追加します。   
         this.c1PrintDocument1.Outlines.Add("RenderText1", rt1);
         // 改ページを追加します。   
         rt1.BreakAfter = C1.C1Preview.BreakEnum.Page;
         // RenderText2を作成します。   
         C1.C1Preview.RenderText rt2 = new C1.C1Preview.RenderText();
         rt2.Text = "This is RenderText2.";
         // RenderText2に対してアウトラインエントリの入力する点を追加します。   
         this.c1PrintDocument1.Outlines.Add("RenderText2", rt2);
         // ドキュメントにRenderTextを追加します。
         this.c1PrintDocument1.Body.Children.Add(rt1);
         this.c1PrintDocument1.Body.Children.Add(rt2);
     }