Page 1 of 2

How to show Multiple report on a single Pdf file on c# code.

Posted: Fri Oct 19, 2012 7:02 am
by nicegaurav
The scenario is ....
I have 2 or 3 report (.mrt files), want to show all report(.mrt files) on pdf when button click, and using c# code for this.
Using below mentioned code for displaying single report direct on the pdf.
StiReportResponse.ResponseAsPdf(this, report, false);
Now i have more than one report and want to show on single pdf file.

How can i do ... :?:

Thanks

Re: How to show Multiple report on a single Pdf file on c# c

Posted: Fri Oct 19, 2012 12:50 pm
by HighAley
Hello.

You could use next code to join your reports:

Code: Select all

            // Open and render report in Millimeters
            StiReport sourceReport = new StiReport();
            sourceReport.Load(@"d:\Millimeters.mrt");
            sourceReport.Compile();
            sourceReport.Render();

            // Now create report in Centimeters and copy rendered page from the first report
            StiReport report = new StiReport();
            report.NeedsCompiling = false;
            report.IsRendered = true;
            report.ReportUnit = StiReportUnitType.Centimeters;

            Stimulsoft.Report.Units.StiUnit newUnit = Stimulsoft.Report.Units.StiUnit.GetUnitFromReportUnit(report.ReportUnit);
            Stimulsoft.Report.Units.StiUnit oldUnit = Stimulsoft.Report.Units.StiUnit.GetUnitFromReportUnit(sourceReport.ReportUnit);
            bool needConvert = report.ReportUnit != sourceReport.ReportUnit;

            report.RenderedPages.Clear();
            foreach (StiPage page in sourceReport.CompiledReport.RenderedPages)
            {
                page.Report = report;
                page.NewGuid();
                if (needConvert) page.Convert(oldUnit, newUnit);
                report.RenderedPages.Add(page);
            }

            report.Show();
Thank you.

Re: How to show Multiple report on a single Pdf file on c# c

Posted: Mon Oct 22, 2012 7:30 am
by nicegaurav
Thanks for ur kind reply..
But I have two different report (on different path) and i have to access both reports on a single pdf with multiple pages..

Is there any way to achieve this functionality.

Thanks

Re: How to show Multiple report on a single Pdf file on c# c

Posted: Mon Oct 22, 2012 12:31 pm
by HighAley
Hello.
nicegaurav wrote:Thanks for ur kind reply..
But I have two different report (on different path) and i have to access both reports on a single pdf with multiple pages..

Is there any way to achieve this functionality.
Here is a modified code from my previous message for your requirement:

Code: Select all

StiReport rep1 = new StiReport();
rep1.Load(@"f:\Support\Report1.mrt");
rep1.Compile();
rep1.Render();

StiReport rep2 = new StiReport();
rep2.Load(@"f:\Support\Report2.mrt");
rep2.Compile();
rep2.Render();

StiReport joinedReport = new StiReport();
joinedReport.NeedsCompiling = false;
joinedReport.IsRendered = true;
joinedReport.RenderedPages.Clear();

foreach (StiPage page in rep1.CompiledReport.RenderedPages)
{
    page.Report = joinedReport;
    page.NewGuid();
    joinedReport.RenderedPages.Add(page);
}

foreach (StiPage page in rep2.CompiledReport.RenderedPages)
{
    page.Report = joinedReport;
    page.NewGuid();
    joinedReport.RenderedPages.Add(page);
}

StiReportResponse.ResponseAsPdf(this, joinedReport, false);
Thank you.

Re: How to show Multiple report on a single Pdf file on c# c

Posted: Thu Oct 25, 2012 9:16 am
by nicegaurav
Thanks a lot...

If we have 10 reports and displaying on single pdf on 10 pages, Can we set the page number on every page.
Like Page 1 of 10, Page 2 of 10 ........ page 10 of 10.

Re: How to show Multiple report on a single Pdf file on c# c

Posted: Fri Oct 26, 2012 6:26 am
by HighAley
Hello.

You could add next code to change text in the Text1 component:

Code: Select all

for (int i = 0; i < report.RenderedPages.Count; i++)
{
    foreach (StiComponent comp in report.RenderedPages[i].Components)
    {
        if (comp.Name == "Text1")
        {
            (comp as StiText).Text = "Page " + (i+1).ToString() + " of " + report.RenderedPages.Count.ToString();
        }
    }
}
Thank you.

Re: How to show Multiple report on a single Pdf file on c# c

Posted: Mon Oct 29, 2012 5:01 am
by nicegaurav
Thanks ... :)

Re: How to show Multiple report on a single Pdf file on c# c

Posted: Mon Oct 29, 2012 7:30 am
by HighAley
Hello.

We are always glad to help you.
Let us know if you need any additional help.

Thank you.

Re: How to show Multiple report on a single Pdf file on c# c

Posted: Wed Nov 19, 2014 10:18 am
by Vaibhav Tambolkar
Hello,

On following below steps the font size of the resulting reports increased to such a level that the values in report are not visible properly.

The steps that I followed

1. Created a joinedreport and set its IsRendered to true and NeedCompiling to false.
2. Created individual reports(Each has a different mrt), compiled and rendered those.
3. Added rendered pages of the individual reports to the joinedreport.
4. Exported joinedreport to a pdf file.

Please let me know if I am missing something here.

Thanks,
Vaibhav

Re: How to show Multiple report on a single Pdf file on c# c

Posted: Thu Nov 20, 2014 5:54 am
by HighAley
Hello.

To answer your question we need to see your code.
Please, send us a sample project that reproduces the issue.

Thank you.