RadRichTextBox with MailMerge functionality

2 posts, 0 answers
  1. Muhammad Ummar
    Muhammad Ummar avatar
    26 posts
    Member since:
    Jul 2012

    Posted 23 May Link to this post

    Hello,

    I am using RadRichTextBox in my project as a reporting tool. I have created a basic structure of application and it seems to be working fine. I am setting MailMergeDataSource to a collection to generate report of more than one selected records. For example If a user selects 10 records, 10 pages will be created in final report. (assuming 1 page per report). User can now edit the generated report (like formatting, refining and so on). Till this point it seems to be achievable. I further want to get all these 10 updated pages of reports separately (with the changes done on the view), I am not sure how to do it.

    Following is the line I am using for MailMerge

     

    radRichTextBox.Document = radRichTextBox.MailMerge(); //Start each record on new page.

     

    I am not sure how to get the boundaries of each report. because if I use the API to regenerate each report the changes done on the print preview will be lost.

    This is what I am talking about

    IDocumentFormatProvider formatProvider = DocumentFormatProvidersManager.GetProviderByExtension(".docx");

    for (int i=0;i<number_of_records; i++)

    this.radRichTextBox.Document.MailMergeDataSource.MoveToFirst();

    var doc = this.radRichTextBox.MailMergeCurrentRecord(); // returns a RadDocument that is the result of substituting the merge fields with the data from the current record.

    byte[] binnaryReportData = formatProvider.Export(doc); //but changes will be lost

    this.radRichTextBox.Document.MailMergeDataSource.MoveToNext();

    }

     

    How can I achieve this?

  2. Muhammad Ummar
    Muhammad Ummar avatar
    26 posts
    Member since:
    Jul 2012

    Posted 25 May Link to this post

    Formatted code 

     

    01.IDocumentFormatProvider formatProvider = DocumentFormatProvidersManager.GetProviderByExtension(".docx");
    02. 
    03.for (int i=0;i<number_of_records; i++)
    04.{
    05.    this.radRichTextBox.Document.MailMergeDataSource.MoveToFirst();
    06.    var doc = this.radRichTextBox.MailMergeCurrentRecord(); // returns a RadDocument that is the result of substituting the merge fields with the data from the current record.
    07.    byte[] binnaryReportData = formatProvider.Export(doc); //but changes will be lost
    08.    this.radRichTextBox.Document.MailMergeDataSource.MoveToNext();
    09.}

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top