cancel
Showing results for 
Search instead for 
Did you mean: 

Exporting using the page server passing parameters to the report

Former Member
0 Kudos

Hi!

I need to export a report to PDF using the PageServer and not using RAS (not use RAS is a requisite), but I need to pass parameters to the report.

There is any way to pass parameters to the report using a code like this?

        SessionMgr sessionMgr = new SessionMgr();

        EnterpriseSession enterpriseSession = sessionMgr.Logon();

        InfoStore infoStore = (InfoStore)enterpriseSession.GetService("InfoStore");

        PSReportFactory ps = (PSReportFactory)enterpriseSession.GetService("PSReportFactory").Interface;

        InfoObject infoObject = infoStore.Query("SELECT * FROM ci_infoobjects WHERE si_name LIKE '%" + "CrystalReport" + "%'")[1];       

        ReportSource rs = (ReportSource)ps.OpenReportSource(infoObject.ID);

        PDFExportFormatOptions fo = new PDFExportFormatOptions();

        fo.StartPageNumber = 1;

        fo.EndPageNumber = 1;

        ExportOptions export = new ExportOptions();

        export.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatPDF;

        export.FormatOptions = fo;

        //Se exporta el informe a un stream de datos, y éste a un array de bytes, que es finalmente el que se escribe en pantalla.

        byte[] contenido = (byte[])rs.Export(export, new RequestContextClass());

        Response.ClearHeaders();

        Response.ClearContent();

        Response.ContentType = "application/pdf";

        Response.AddHeader("Content-Disposition", "attachment; filename=" + "Jur.pdf");

        Response.BinaryWrite(contenido);

Regards,

César

Accepted Solutions (0)

Answers (1)

Answers (1)

jos_dealmeida
Explorer
0 Kudos

Hi,

Has someone found a solution for that issue ?

I've got the same question.

Best regards

former_member188030
Active Contributor
0 Kudos

Hi,

Could not test the code you have provided.

But take a look at below sample, might help.

Thanks,

Bhushan