Friday, March 9, 2012

Possible to render direct to PDF instead of viewing the report on a webpage?

Is it possible to to render direct to PDF when viewing the report url?

Hello,

Try adding the part in red to your URL:

http://ServerName/Reportserver/Pages/Report.aspx?ItemPath=%2fReportPath%2fReportName&rs:Command=Render&rs:Format=PDF

Hope this helps.

Jarret

|||

Will check that out in the beginning of the next week.

Thanks!!!

|||

Jarret wrote:

Hello,

Try adding the part in red to your URL:

http://ServerName/Reportserver/Pages/Report.aspx?ItemPath=%2fReportPath%2fReportName&rs:Command=Render&rs:Format=PDF

Hope this helps.

Jarret

Jarret is right, however it is better not to render from http://servername/reportserver/?/ReportPath/ReportName&rs:Format=PDF

The server will automatically redirect you to the ./Pages/Report.aspx part, but that is really an implementation detail and could change in the future.

|||

Hi

I′ve tested to do it like this and it works if parameters needed for the report are passed in the the url-string.

The problem is if you would like the user to write in a parameter (eg. orderno) to the report, this solution won′t work.

It seems like it have to go through the standard way, via the HTML-page if orderno needs to be set.

Any Ideas how to solve this?

|||

private void CreatePDF()

{

try

{

Microsoft.Reporting.WebForms.Warning[] warn;

string[] streamids;

string mimeType = "application/pdf";

string encoding = string.Empty;

string extension = string.Empty;

byte[] byteViewer;

byteViewer = ReportViewerMain.ServerReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warn);

Response.Buffer = true;

Response.Clear();

Response.ContentType = "application/pdf";

Response.AddHeader("content-disposition", "inline; filename=myReport.pdf");

Response.BinaryWrite(byteViewer);

Response.Flush();

Response.End();

streamids = null;

byteViewer = null;

}

catch (Exception ex)

{

ExceptionManager.Sys(ex);

}

}

|||

Hi there

Should I put this code in custome code? Any references needed?

No comments:

Post a Comment