Step 5 - Merge multiple Documents

ASP User's Guide > Simple Sample Programs

A very useful feature of TX Text Control is the capability to merge documents with different text formats into one document. For instance, you can generate a new document from code and add a Microsoft Word document or a document formatted with another supported format to this document. There are several cases when such a feature is useful, e.g. generating an invoice and adding legal information to it.

The following code fragment sets the current input position to the end of the current document and appends the demo document installed with the TX Text Control installation program:

tx.SelStart = Len(tx.Text)
tx.SelLength = 0
' add a page break
tx.SelText = Chr(12)
' insert the demo document
tx.Load Server.MapPath("demo.rtf"), 0, 5, true

As you can see, the Load method has three additional parameters, besides the file name of the document. The first specifies the zero-based file position from where the data is to be read (in this case 0, because the complete demo document is added). The second specifies the format identifier and the last parameter is a boolean value, which must be set to True if a document is to be inserted. Otherwise, if set to False the merged document would replace the current document.