ConvertFieldsToStaticText() 공개 정적인 메소드

Converts any fields of the specified type found in the descendants of the node into static text.
public static ConvertFieldsToStaticText ( CompositeNode compositeNode, FieldType targetFieldType ) : void
compositeNode CompositeNode The node in which all descendants of the specified FieldType will be converted to static text.
targetFieldType FieldType The FieldType of the field to convert to static text.
리턴 void
        public static void Run()
        {
            //ExStart:ConvertFieldsInDocument
            // 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 encountered in the document (including headers and footers) to static text.
            FieldsHelper.ConvertFieldsToStaticText(doc, FieldType.FieldIf);

            dataDir = dataDir + RunExamples.GetOutputFilePath(fileName);
            // Save the document with fields transformed to disk.
            doc.Save(dataDir);
            //ExEnd:ConvertFieldsInDocument
            Console.WriteLine("\nConverted fields to static text in the document successfully.\nFile saved at " + dataDir);
        }
        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);
        }