public HttpResponseMessage RelPacientes() { try { var lista = _serviceRelatorio.RelPacientes(base.GetUsuarioLogado().IdClinica); //vinculando dataset ao objeto relat var ds = new ReportDataSource(); ds.Name = "dsdados"; ds.Value = lista; var report = new LocalReport() { ReportPath = AppDomain.CurrentDomain.BaseDirectory + "Report/RelatorioPacientes.rdlc" }; report.DataSources.Add(ds); report.Refresh(); ReportParameter[] parametros = new ReportParameter[] { new ReportParameter("usuario", base.GetUsuarioLogado().Nome) }; report.SetParameters(parametros); //configurações da página ex: margin, top, left ... string deviceInfo = "<DeviceInfo>" + "<OutputFormat>PDF</OutputFormat>" + "<PageWidth>29.7cm</PageWidth>" + "<PageHeight>21cm</PageHeight>" + "<MarginTop>0.5cm</MarginTop>" + "<MarginLeft>0.5cm</MarginLeft>" + "<MarginRight>0.5cm</MarginRight>" + "<MarginBottom>0.5cm</MarginBottom>" + "</DeviceInfo>"; string mimeType = ""; string encoding = ""; string filenameExtension = ""; string[] streams = null; Microsoft.Reporting.WebForms.Warning[] warnings = null; byte[] bytes = report.Render("PDF", deviceInfo, out mimeType, out encoding, out filenameExtension, out streams, out warnings); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new ByteArrayContent(bytes); result.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(mimeType); return(result); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }