public void MergeDocumentTest()
        {
            try
            {
                ReportingCloud rc = new ReportingCloud(sUsername, sPassword, uriBasePath);

                // upload 1 more document with unique file name
                byte[] bDocument     = File.ReadAllBytes("documents/invoice.tx");
                string sTempFilename = "test" + Guid.NewGuid().ToString() + ".tx";
                rc.UploadTemplate(sTempFilename, bDocument);

                List <Invoice> invoices = new List <Invoice>();

                // create dummy data
                Invoice invoice = new Invoice();
                invoice.yourcompany_companyname = "Text Control, LLC";
                invoice.invoice_no  = "Test_R667663";
                invoice.billto_name = "<html><strong>Test</strong> <em>Company</em></html>";

                Invoice invoice2 = new Invoice();
                invoice2.yourcompany_companyname = "Text Control 2, LLC";
                invoice2.invoice_no  = "Test_R667663";
                invoice2.billto_name = "<html><strong>Test</strong> <em>Company</em></html>";

                invoices.Add(invoice);
                invoices.Add(invoice2);

                // create a new MergeBody object
                MergeBody body = new MergeBody();
                body.MergeData = invoices;

                MergeSettings settings = new MergeSettings();
                settings.Author    = "Text Control GmbH";
                settings.MergeHtml = true;
                settings.Culture   = "de-DE";

                body.MergeSettings = settings;

                // merge the document
                List <byte[]> results = rc.MergeDocument(body, sTempFilename, ReturnFormat.HTML, false, false);

                string bHtmlDocument = System.Text.Encoding.UTF8.GetString(results[0]);

                // check whether the created HTML contains the test string
                Assert.IsTrue(bHtmlDocument.Contains("Test_R667663"));

                // delete the template
                rc.DeleteTemplate(sTempFilename);
            }
            catch (Exception exc)
            {
                Assert.Fail(exc.Message);
            }
        }
        public List <byte[]> GenerateReport(Report report, JArray data)
        {
            if (!connector.TemplateExists(report.TemplateName))
            {
                throw new Exception($"Template {report.TemplateName} does not exist.");
            }

            var files = connector.MergeDocument(new MergeBody()
            {
                MergeData = data
            }, report.TemplateName,
                                                append: false,
                                                test: IsTest);

            return(files);
        }