What is the best what to copy text from one document to another


https://www.nevron.com/Forum/Topic12947.aspx
Print Topic | Close Window

By Mike Willis - 4 Years Ago
Hi,
I am using OpenVision Enterprise
What is the recommended way to copy text from one document to another, both opened in memory?
Specifically i want to do a mail merge in one document, and copy the resulting merge to another document.
Thanks, 
Mike Willis

By Nevron Support - 4 Years Ago
Hi Mike,
There are generally two ways to do this fast:
1. You can use deep clone on the view.Content for example:
NDocumentBlock block = (NDocumentBlock)nRichTextViewWithRibbonControl1.View.Content.DeepClone();
nRichTextViewWithRibbonControl2.View.Content = block;
or 
2. You can save / load the document to a memory stream:
MemoryStream memoryStream = new MemoryStream();
nRichTextViewWithRibbonControl1.View.SaveToStream(memoryStream, new NNevronXMLTextFormat(), null);
memoryStream.Seek(0, SeekOrigin.Begin);
nRichTextViewWithRibbonControl2.View.LoadFromStream(memoryStream, new NNevronXMLTextFormat());

We would recommend you to use the first approach as there is no added overhead of XML formatting. Let us know if you have any questions.