当前位置: 首页>>代码示例>>C#>>正文


C# DocumentBuilder.InsertTableOfContents方法代码示例

本文整理汇总了C#中DocumentBuilder.InsertTableOfContents方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentBuilder.InsertTableOfContents方法的具体用法?C# DocumentBuilder.InsertTableOfContents怎么用?C# DocumentBuilder.InsertTableOfContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocumentBuilder的用法示例。


在下文中一共展示了DocumentBuilder.InsertTableOfContents方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert a table of contents at the beginning of the document.
            builder.InsertTableOfContents("\\o \"1-3\" \\h \\z \\u");

            // The newly inserted table of contents will be initially empty.
            // It needs to be populated by updating the fields in the document.
            doc.UpdateFields();
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:12,代码来源:Program.cs

示例2: Run

        public static void Run()
        {
            // ExStart:DocumentBuilderInsertTOC
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithDocument();
            // Initialize document.
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert a table of contents at the beginning of the document.
            builder.InsertTableOfContents("\\o \"1-3\" \\h \\z \\u");

            // The newly inserted table of contents will be initially empty.
            // It needs to be populated by updating the fields in the document.
            // ExStart:UpdateFields
            doc.UpdateFields();
            // ExEnd:UpdateFields
            dataDir = dataDir + "DocumentBuilderInsertTOC_out.doc";
            doc.Save(dataDir);
            // ExEnd:DocumentBuilderInsertTOC
            Console.WriteLine("\nTable of contents field inserted successfully into a document.\nFile saved at " + dataDir);
        }     
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:22,代码来源:DocumentBuilderInsertTOC.cs

示例3: InsertTableOfContents

        public static void InsertTableOfContents(string dataDir)
        {
            // ExStart:DocumentBuilderInsertTableOfContents
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert a table of contents at the beginning of the document.
            builder.InsertTableOfContents("\\o \"1-3\" \\h \\z \\u");

            // Start the actual document content on the second page.
            builder.InsertBreak(BreakType.PageBreak);

            // Build a document with complex structure by applying different heading styles thus creating TOC entries.
            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;

            builder.Writeln("Heading 1");

            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;

            builder.Writeln("Heading 1.1");
            builder.Writeln("Heading 1.2");

            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;

            builder.Writeln("Heading 2");
            builder.Writeln("Heading 3");

            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;

            builder.Writeln("Heading 3.1");

            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading3;

            builder.Writeln("Heading 3.1.1");
            builder.Writeln("Heading 3.1.2");
            builder.Writeln("Heading 3.1.3");

            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;

            builder.Writeln("Heading 3.2");
            builder.Writeln("Heading 3.3");

            doc.UpdateFields();
            dataDir = dataDir + "DocumentBuilderInsertTableOfContents_out.doc";
            doc.Save(dataDir);
            // ExEnd:DocumentBuilderInsertTableOfContents
            Console.WriteLine("\nTable of contents using DocumentBuilder inserted successfully into a document.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:48,代码来源:DocumentBuilderInsertElements.cs

示例4: DocumentBuilderInsertTOC

        public void DocumentBuilderInsertTOC()
        {
            //ExStart
            //ExId:DocumentBuilderInsertTOC
            //ExSummary:Shows how to insert a Table of Contents field into a document.
            Aspose.Words.Document doc = new Aspose.Words.Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert a table of contents at the beginning of the document.
            builder.InsertTableOfContents("\\o \"1-3\" \\h \\z \\u");

            // The newly inserted table of contents will be initially empty.
            // It needs to be populated by updating the fields in the document.
            doc.UpdateFields();
            //ExEnd
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:16,代码来源:ExDocumentBuilder.cs

示例5: InsertToc

        public void InsertToc()
        {
            //ExStart
            //ExFor:DocumentBuilder.InsertTableOfContents
            //ExFor:Document.UpdateFields
            //ExFor:DocumentBuilder.#ctor(Document)
            //ExFor:ParagraphFormat.StyleIdentifier
            //ExFor:DocumentBuilder.InsertBreak
            //ExFor:BreakType
            //ExId:InsertTableOfContents
            //ExSummary:Demonstrates how to insert a Table of contents (TOC) into a document using heading styles as entries.
            // Use a blank document
            Aspose.Words.Document doc = new Aspose.Words.Document();

            // Create a document builder to insert content with into document.
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert a table of contents at the beginning of the document.
            builder.InsertTableOfContents("\\o \"1-3\" \\h \\z \\u");

            // Start the actual document content on the second page.
            builder.InsertBreak(BreakType.PageBreak);

            // Build a document with complex structure by applying different heading styles thus creating TOC entries.
            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;

            builder.Writeln("Heading 1");

            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;

            builder.Writeln("Heading 1.1");
            builder.Writeln("Heading 1.2");

            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;

            builder.Writeln("Heading 2");
            builder.Writeln("Heading 3");

            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;

            builder.Writeln("Heading 3.1");

            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading3;

            builder.Writeln("Heading 3.1.1");
            builder.Writeln("Heading 3.1.2");
            builder.Writeln("Heading 3.1.3");

            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;

            builder.Writeln("Heading 3.2");
            builder.Writeln("Heading 3.3");

            // Call the method below to update the TOC.
            doc.UpdateFields();
            //ExEnd

            doc.Save(ExDir + "DocumentBuilder.InsertToc Out.docx");
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:59,代码来源:ExDocumentBuilder.cs

示例6: Run

        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_QuickStart();

            // Demonstrates how to insert fields and update them using Aspose.Words.

            // First create a blank document.
            Document doc = new Document();

            // Use the document builder to insert some content and fields.
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert a table of contents at the beginning of the document.
            builder.InsertTableOfContents("\\o \"1-3\" \\h \\z \\u");
            builder.Writeln();

            // Insert some other fields.
            builder.Write("Page: ");
            builder.InsertField("PAGE");
            builder.Write(" of ");
            builder.InsertField("NUMPAGES");
            builder.Writeln();

            builder.Write("Date: ");
            builder.InsertField("DATE");

            // Start the actual document content on the second page.
            builder.InsertBreak(BreakType.SectionBreakNewPage);

            // Build a document with complex structure by applying different heading styles thus creating TOC entries.
            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;

            builder.Writeln("Heading 1");

            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;

            builder.Writeln("Heading 1.1");
            builder.Writeln("Heading 1.2");

            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;

            builder.Writeln("Heading 2");
            builder.Writeln("Heading 3");

            // Move to the next page.
            builder.InsertBreak(BreakType.PageBreak);

            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;

            builder.Writeln("Heading 3.1");

            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading3;

            builder.Writeln("Heading 3.1.1");
            builder.Writeln("Heading 3.1.2");
            builder.Writeln("Heading 3.1.3");

            builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;

            builder.Writeln("Heading 3.2");
            builder.Writeln("Heading 3.3");

            Console.WriteLine("Updating all fields in the document.");

            // Call the method below to update the TOC.
            doc.UpdateFields();

            doc.Save(dataDir + "Document Field Update Out.docx");

            Console.WriteLine("\nFields updated successfully.\nFile saved at " + dataDir + "Document Field Update Out.docx");
        }
开发者ID:robv8r,项目名称:Aspose_Words_NET,代码行数:72,代码来源:UpdateFields.cs


注:本文中的DocumentBuilder.InsertTableOfContents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。