|
|||||||
| TX Text Control .NET Server Please use this forum for TX Text Control .NET Server support only. If you need support for a different product, please use the appropriate forum. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Merging Multiple Documents into One Document
Hi. I am relatively new to TxTextControl and am having trouble merging multiple documents into one document.
I have no problem creating a pdf from a DOCX template if I just want to generate a single document but merging multiple documents into one doesn't seem to work for me. I am sure I am doing something silly in my code. I have included a simplified version of my code below. can anyone see what I am doing wrong? Thanks in advance for any help. For the sample code below for simplification purposes I am just assuming I use 3 basic file templates that each contain the data field "Col1". At the end I would want to see the 3 docs contained in a single pdf. When I execute the code below currently the docstream contains just the last document only(nothing from documents 1 and 2). Code:
// declare variables
TXTextControl.ServerTextControl control;
TXTextControl.DocumentServer.MailMerge template;
control = new TXTextControl.ServerTextControl();
template = new TXTextControl.DocumentServer.MailMerge();
TXTextControl.SaveSettings settings = new TXTextControl.SaveSettings();
string TemplatePath = "";
byte[] docstream = null;
// loop to merge 3 docs into one
for(int i=0; i<3; i++)
{
// set up data for this doc
TemplatePath = "c:\test\testtemplate" + i.ToString() + ".docx";
DataTable tab = new DataTable();
tab.Columns.Add("Col1");
tab.Rows.Add("value 1");
template.TextComponent = control; // set TextComponent to the relevant Template
template.LoadTemplate(TemplatePath, TXTextControl.DocumentServer.FileFormat.WordprocessingML);
template.Merge(tab, true);
}
// return back the combined doc as an outout stream
template.SaveDocumentToMemory(out docstream,TXTextControl.BinaryStreamType.AdobePDF, settings);
Last edited by brycare; February 15, 2010 at 11:59:10. Reason: Please use [code][/code] tags when posting source code. |
|
#2
|
||||
|
||||
|
Re: Merging Multiple Documents into One Document
Hey there,
To combine documents, the MailMerge method is not the correct method. Please use the Append method to add documents to your existing document.
__________________
Regards, Gunnar Giffey, TX Text Control [Forum Administrator] |
|
#3
|
|||
|
|||
|
Re: Merging Multiple Documents into One Document
Thanks for your reply.
Do I not need to use the MailMerge anyway in order to populate the data fields? If each of the 3 documents contains data fields I assumed I would still need to call the Merge method? |
|
#4
|
||||
|
||||
|
Re: Merging Multiple Documents into One Document
MailMerge is for populating text field, Append is for combining documents, so you could use MailMerge on the complete document.
However, the longer the document, the more time consuming is the mail merge process, so I suggest to perform the mail merge process on smaller or single documents if possible.
__________________
Regards, Gunnar Giffey, TX Text Control [Forum Administrator] |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Merging header from one document with body from another | gclark | TX Text Control .NET Server | 5 | January 21, 2009 11:49:54 |
| Merging documents with different page settings into one single document | Jebo | TX Text Control Feature Requests | 0 | June 20, 2008 00:41:22 |
| Reset page numbers for a merged document | DotNetUSA | TX Text Control .NET Server | 4 | July 19, 2007 16:18:39 |
| Merging Multiple RTF's With Footers | Unregistered | TX Text Control ActiveX Server | 1 | July 15, 2004 13:34:06 |
| Mail Mergeing Multiple Records in one Document | stephenk | TX Text Control .NET | 3 | February 3, 2004 01:24:43 |