C1MultiDocument component allows creating, persisting, and exporting large documents that cannot be handled by a single C1PrintDocument object due to memory limitations. This was added in C1Reports in 2011v2 release. Using C1MultiDocument we can handle not just C1PrintDocument but also other components, like C1Report and C1RDLReport, offered by ComponentOne Reports for .Net. In this blog we will discuss how can C1MultiDocument be used to merge different report components (C1Report/C1RDLReport/C1PrintDocument)

Implementation

A C1MultiDocument is basically a collection of elements of type C1MultiDocumentItem. Each such element represents a single C1PrintDocument. When combined within a C1MultiDocument, all these documents are rendered as a single document. Hence, in order to add C1Report and C1RDLReport to the item collection of C1MultiDocument, we need to access their C1Document property. The C1PrinDocument can be directly added to C1MultiDocument's Item collection. Please note, that C1MultiDocument can be previewed in C1PrintPreviewControl like any other C1Report/C1RDLReport/C1PrintDocument Following is the code that we need to use :

'Load C1Report/'C1RDLreport/C1PrinDocument  
 C1Report1.Load(OpenFileDialog1.FileName.ToString, Reportlist.SelectedItem)  
 C1RdlReport1.Load(OpenFileDialog1.FileName)  
 C1PrintDocument1.Load(OpenFileDialog1.FileName)  

'Merging different formats in one C1MultiDocument  
 C1MultiDocument1.Items.Add(C1Report1.C1Document)  
 C1MultiDocument1.Items.Add(C1PrintDocument1)  
 C1MultiDocument1.Items.Add(C1RdlReport1.C1Document)

Please refer to the attached sample for complete implementation. We can further use this resultant merged document for exporting/printing purposes. Download VB Sample Download C# Sample