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


C# Document.UpdateFields方法代码示例

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


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

示例1: UpdateToc

        public void UpdateToc()
        {
            Document doc = new Document();

            //ExStart
            //ExId:UpdateTOC
            //ExSummary:Shows how to completely rebuild TOC fields in the document by invoking field update.
            doc.UpdateFields();
            //ExEnd
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:10,代码来源:ExField.cs

示例2: Main

        static void Main(string[] args)
        {
            string MyDir = @"F:\Dropbox\Personal\Aspose Vs OpenXML\Features Supported by Aspose not Open XML\Aspose.Words Features\Field Update\Data\";
            Document doc = new Document(MyDir + "Rendering.docx");

            // This updates all fields in the document.
            doc.UpdateFields();

            doc.Save(MyDir + "Rendering.UpdateFields Out.pdf");
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:10,代码来源:Program.cs

示例3: 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

示例4: Run

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

            Document doc = new Document(dataDir + "Rendering.doc");

            // This updates all fields in the document.
            doc.UpdateFields();
            dataDir = dataDir + "Rendering.UpdateFields_out.pdf";
            doc.Save(dataDir);
            // ExEnd:UpdateDocFields
            Console.WriteLine("\nDocument fields updated successfully.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:15,代码来源:UpdateDocFields.cs

示例5: VisitDocumentEnd

        public override VisitorAction VisitDocumentEnd(Document doc)
        {
            // All sections have separate headers and footers now, update the fields in all headers and footers
            // to the correct values. This allows each page to maintain the correct field results even when
            // PAGE or IF fields are used.
            doc.UpdateFields();

            foreach (HeaderFooter headerFooter in doc.GetChildNodes(NodeType.HeaderFooter, true))
            {
                foreach (Field field in headerFooter.Range.Fields)
                    field.IsLocked = true;
            }

            return VisitorAction.Continue;
        }
开发者ID:nancyeiceblue,项目名称:Aspose_Words_NET,代码行数:15,代码来源:SectionSplitter.cs

示例6: Main

        static void Main(string[] args)
        {
            string mypath = "";
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);
            // Create the headers.
            builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
            builder.Write("Header Text goes here...");
            //add footer having current date
            builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
            builder.InsertField("Date", "");

            doc.UpdateFields();
            doc.Save(mypath + "Insert Headers and Footers.doc");
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:15,代码来源:Program.cs

示例7: 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

示例8: GenerateDoc


//.........这里部分代码省略.........
                    value = configData.DocumentValues[Bookmarks.SALTEA_LOGO];
                }

                if (string.IsNullOrEmpty(value))
                {
                    if (configData.DocumentValues.ContainsKey(Bookmarks.SAP_LOGO))
                    {
                        value = configData.DocumentValues[Bookmarks.SAP_LOGO];
                    }
                }

                if (string.IsNullOrEmpty(value))
                {
                    if (configData.DocumentValues.ContainsKey(Bookmarks.BRA_LOGO) && (doc.Variables[Bookmarks.BRA_DESC] == Bookmarks.ELECTRONIC || configData.DocType == 3 || configData.IsGenerateTaskDocument))
                    {
                        value = configData.DocumentValues[Bookmarks.BRA_LOGO];
                    }
                }
                    if (!string.IsNullOrEmpty(value))
                    {
                        string logoPath = path + "\\logos\\" + value;
                        if(File.Exists(logoPath))
                            InsertImage(doc, Bookmarks.LOGO, logoPath);
                    }
            }

            if (configData.ShowWaterMark)
            {
                InsertWatermarkText(doc, Bookmarks.DRAFT);
            }

            try
            {
                doc.UpdateFields();
                doc.Range.UpdateFields();
            }
            catch (Exception)
            {
                // Error sometimes occurrs in Aspose when calling UpdateFields.
            }

            NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);

            foreach (Paragraph para in paragraphs)
            {
                if (para.IsListItem)
                {
                    foreach (Node node in para.ChildNodes)
                    {
                        Run run = node as Run;

                        if (run != null)
                        {
                            bool runBeginsWithATab = run.Range.Text.Count() > 0 && run.Range.Text[0] == '\t';

                            if (runBeginsWithATab)
                            {
                                run.Text = run.Range.Text.Remove(0, 1);
                            }
                        }
                    }
                }
            }

            MemoryStream stream = new MemoryStream();
            doc.BuiltInDocumentProperties.LastSavedTime = DateTime.UtcNow;
开发者ID:khangtran-steadfast,项目名称:DatabaseConversion,代码行数:67,代码来源:WordGenerator.cs

示例9: 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

示例10: 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

示例11: UpdateFields

 public void UpdateFields()
 {
     //ExStart
     //ExFor:Document.UpdateFields
     //ExId:UpdateFieldsInDocument
     //ExSummary:Shows how to update all fields in a document.
     Document doc = new Document(MyDir + "Document.doc");
     doc.UpdateFields();
     //ExEnd
 }
开发者ID:nausherwan-aslam,项目名称:Aspose_Words_NET,代码行数:10,代码来源:ExDocument.cs

示例12: DocumentBuilderInsertTOC

        public void DocumentBuilderInsertTOC()
        {
            //ExStart
            //ExId:DocumentBuilderInsertTOC
            //ExSummary:Shows how to insert a Table of Contents field into a 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.
            doc.UpdateFields();
            //ExEnd
        }
开发者ID:nausherwan-aslam,项目名称:Aspose_Words_NET,代码行数:16,代码来源:ExDocumentBuilder.cs

示例13: 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
            Document doc = new 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(MyDir + "DocumentBuilder.InsertToc Out.docx");
        }
开发者ID:nausherwan-aslam,项目名称:Aspose_Words_NET,代码行数:59,代码来源:ExDocumentBuilder.cs

示例14: InsertFieldWithFieldBuilder

        public void InsertFieldWithFieldBuilder()
        {
            Document doc = new Document();

            //Add some text into the paragraph
            Run run = DocumentHelper.InsertNewRun(doc, " Hello World!", 0);

            FieldArgumentBuilder argumentBuilder = new FieldArgumentBuilder();
            argumentBuilder.AddField(new FieldBuilder(FieldType.FieldMergeField));
            argumentBuilder.AddText("BestField");

            FieldBuilder fieldBuilder = new FieldBuilder(FieldType.FieldIf);
            fieldBuilder.AddArgument(argumentBuilder)
                .AddArgument("=")
                .AddArgument("BestField")
                .AddArgument(10)
                .AddArgument(20.0)
                .AddSwitch("12", "13")
                .BuildAndInsert(run);

            doc.UpdateFields();
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:22,代码来源:ExField.cs

示例15: GenerateBodyDoc


//.........这里部分代码省略.........
                        if (
                            docVarName.StartsWith("ai_", true, CultureInfo.CurrentCulture)
                            || docVarName.StartsWith("ae_", true, CultureInfo.CurrentCulture)
                            || docVarName.StartsWith("ab_", true, CultureInfo.CurrentCulture)
                            )
                        {
                            docVarName = docVarName.Substring(3);
                        }
                        string keyA;
                        if (docVarName.StartsWith("CI___", true, CultureInfo.CurrentCulture) && !TryGetKeyWithCorrectCase(docValues.Keys, docVarName, out keyA))//docValues.ContainsKey(docVarName))
                        {
                            docVarName = docVarName.Substring(5);

                            string keyD;
                            if (TryGetKeyWithCorrectCase(docValues.Keys, "I___" + docVarName, out keyD)) // (docValues.ContainsKey("I___" + docVarName))
                            {
                                docVarName = keyD;
                            }
                        }
                        try
                        {
                            string keyB;
                            if (TryGetKeyWithCorrectCase(docValues.Keys, docVarName, out keyB) && docValues[keyB] != null)//(docValues.ContainsKey(docVarName) && docValues[docVarName] != null)
                            {
                                doc.Variables[match.Groups["name"].Value] = docValues[keyB];
                            }
                            else
                            {
                                string keyC;
                                if (TryGetKeyWithCorrectCase(docValues.Keys, "I___" + docVarName, out keyC) && docValues[keyC] != null) //(docValues.ContainsKey("I___" + docVarName) && docValues[docVarName] != null)
                                {
                                    doc.Variables[match.Groups["name"].Value] = docValues[keyC];
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            doc.UpdateFields();

            if (schedule  != null && schedule.Count() > 0)
            {
                try
                {

                    using (MemoryStream rtfStream = new MemoryStream(schedule))
                    {
                        Document rtfDoc = new Document(rtfStream);
                        InsertDocumentAtBookmark(Bookmarks.POL_PARTICULARS, doc, rtfDoc);
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            if (notice1 != null && notice1.Count() > 0)
            {
                try
                {

                    using (MemoryStream rtfStream = new MemoryStream(notice1))
                    {
                        Document rtfDoc = new Document(rtfStream);
                        InsertDocumentAtBookmark(Bookmarks.FSRA_NOTICE1, doc, rtfDoc);
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            if (draft)
            {
                InsertWatermarkText(doc,Bookmarks.DRAFT);
            }

            using (MemoryStream stream = new MemoryStream())
            {

                try
                {
                    doc.Save(stream, saveFormat);
                }
                catch (Exception e)
                {
                    throw e;
                }

                return stream.ToArray();
            }
        }
开发者ID:khangtran-steadfast,项目名称:DatabaseConversion,代码行数:101,代码来源:WordGenerator.cs


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