This is a migrated thread and some comments may be shown as answers.

is Possibile Merge two Documents?

5 Answers 148 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Luciano
Top achievements
Rank 1
Luciano asked on 18 Aug 2010, 03:04 PM

IDocumentFormatProvider

 

 

provider = new DocxFormatProvider();

 

 

 

doc1 = provider.Import(s1);
doc2 = provider.Import(s2);

 

 

 

 

 

docMerge = ? 

 

 

Thank

 

5 Answers, 1 is accepted

Sort by
0
Alex
Telerik team
answered on 19 Aug 2010, 03:32 PM
Hi Luciano,

Basically what you need to do is to make selection over the first document and then copy it at the end of the other. I've attached a sample project that demonstrates this approach (you will have to fix the references to Telerik.Windows.Documents and Telerik.Windows.Documents.FormatProviders.OpenXml assemblies).

I hope this is helpful.

Kind regards,
Alex
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Luciano
Top achievements
Rank 1
answered on 20 Aug 2010, 09:25 AM
Thanks.

In the Example Merge result Second Document + First Document. Why?

position.MoveToLastPositionInDocument();

 

 

//insert the copied content

 

doc1.InsertFragment(fragment, position);

0
Mike
Telerik team
answered on 23 Aug 2010, 03:53 PM
Hi Luciano,

Please try the following:

doc1.CaretPosition.MoveToLastPositionInDocument();
doc1.InsertFragment(fragment);
Let us know how it goes.

All the best,
Mike
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kevin
Top achievements
Rank 1
answered on 23 Aug 2010, 04:10 PM
Mike,

Your follow up works.

New question, how would you insert the document after a new page break?  Load doc1, page break, load doc2.
0
Ivailo Karamanolev
Telerik team
answered on 24 Aug 2010, 07:11 AM
Hello Kevin,

The way to insert a page break is
doc1.InsertInline(new Span(FormattingSymbolLayoutBox.PAGE_BREAK));
You should add that just before you insert the second document.
Get back to us if you have any further questions.

All the best,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
RichTextBox
Asked by
Luciano
Top achievements
Rank 1
Answers by
Alex
Telerik team
Luciano
Top achievements
Rank 1
Mike
Telerik team
Kevin
Top achievements
Rank 1
Ivailo Karamanolev
Telerik team
Share this question
or