Aspose.Words.Examples.CSharp.Programming_Documents.Working_With_Document.RemoveBreaks.Run C# (CSharp) Method

Run() public static method

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

            // Remove the page and section breaks from the document.
            // In Aspose.Words section breaks are represented as separate Section nodes in the document.
            // To remove these separate sections the sections are combined.
            RemovePageBreaks(doc);
            RemoveSectionBreaks(doc);

            dataDir = dataDir + RunExamples.GetOutputFilePath(fileName);
            // Save the document.
            doc.Save(dataDir);
        
            Console.WriteLine("\nRemoved breaks from the document successfully.\nFile saved at " + dataDir);
        }
        // ExStart:RemovePageBreaks