Aspose.Words.Examples.CSharp.Programming_Documents.Joining_and_Appending.PrependDocument.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_JoiningAndAppending();
            string fileName = "TestFile.Destination.doc";

            Document dstDoc = new Document(dataDir + fileName);
            Document srcDoc = new Document(dataDir + "TestFile.Source.doc");

            // Append the source document to the destination document. This causes the result to have line spacing problems.
            dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);

            // Instead prepend the content of the destination document to the start of the source document.
            // This results in the same joined document but with no line spacing issues.
            DoPrepend(srcDoc, dstDoc, ImportFormatMode.KeepSourceFormatting);

            dataDir = dataDir + RunExamples.GetOutputFilePath(fileName);
            // Save the document
            dstDoc.Save(dataDir);

            Console.WriteLine("\nDocument prepended successfully.\nFile saved at " + dataDir);
        }
PrependDocument