Aspose.Words.Examples.CSharp.Programming_Documents.Bookmarks.CopyBookmarkedText.Run C# (CSharp) Метод

Run() публичный статический Метод

public static Run ( ) : void
Результат void
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithBookmarks();
            string fileName = "Template.doc"; 

            // Load the source document.
            Document srcDoc = new Document(dataDir + fileName);

            // This is the bookmark whose content we want to copy.
            Bookmark srcBookmark = srcDoc.Range.Bookmarks["ntf010145060"];

            // We will be adding to this document.
            Document dstDoc = new Document();

            // Let's say we will be appending to the end of the body of the last section.
            CompositeNode dstNode = dstDoc.LastSection.Body;

            // It is a good idea to use this import context object because multiple nodes are being imported.
            // If you import multiple times without a single context, it will result in many styles created.
            NodeImporter importer = new NodeImporter(srcDoc, dstDoc, ImportFormatMode.KeepSourceFormatting);

            // Do it once.
            AppendBookmarkedText(importer, srcBookmark, dstNode);

            // Do it one more time for fun.
            AppendBookmarkedText(importer, srcBookmark, dstNode);

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

            Console.WriteLine("\nBookmark copied successfully.\nFile saved at " + dataDir);
        }
CopyBookmarkedText