Aspose.Words.Examples.CSharp.Programming_Documents.Working_with_Fields.ConvertFieldsInParagraph.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            // ExStart:ConvertFieldsInParagraph
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithFields();
            string fileName = "TestFile.doc";
            Document doc = new Document(dataDir + fileName);

            // Pass the appropriate parameters to convert all IF fields to static text that are encountered only in the last 
            // Paragraph of the document.
            FieldsHelper.ConvertFieldsToStaticText(doc.FirstSection.Body.LastParagraph, FieldType.FieldIf);

            dataDir = dataDir + RunExamples.GetOutputFilePath(fileName);
            // Save the document with fields transformed to disk.
            doc.Save(dataDir);
            // ExEnd:ConvertFieldsInParagraph
            Console.WriteLine("\nConverted fields to static text in the paragraph successfully.\nFile saved at " + dataDir);
        }
    }
ConvertFieldsInParagraph