Question

i'm working in a mvc4 web application and i'm trying to export a report "Crystal Report" to a pdf file. My problem is when i want to export more than one report into the same pdf file. Do somebody have any idea to do that? I can export one report to a pdf file with the following code:

public ActionResult ReporteListadoUnidades(int idConsorcio, int? idCentroCosto)
    {
        try
        {

            DataSet datos = new DataSet();

            LoadDatos(ref datos);

            ....

            ReportDocument rptCV = new ReportDocument();
            rptCV.Load(Server.MapPath("~/Reports/repUnidades.rpt"));
            rptCV.SetDataSource(datos);

            Stream stream = rptCV.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            return File(stream, "application/pdf");
        }
        catch (Exception)
        {
            throw;
        }
    }

And the result is the following: (Image not available because i don't have reputation to post it)

As you can see, all of this run well, but i would like to export different reports together in the same pdf file.

Was it helpful?

Solution

You will have to use a 3rd party library such as PDFSharp, iTextSharp or atalasoft. They will support merging multiple streams (or files, which ever way you want to do it) into one stream (or file) then writing it like normal.

Do you care about bookmarks in the document? That makes things a little harder.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top