Exemple #1
0
        public HttpResponseMessage getPDF(string RegistroClinicoId)
        {
            var response = new HttpResponseMessage(HttpStatusCode.OK);

            try
            {
                var service  = new PDFService();
                var registro = service.PDFRegistroHistoria(RegistroClinicoId);


                var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
                var pdfBytes  = htmlToPdf.GeneratePdf(registro);

                var stream = new MemoryStream(pdfBytes);
                response.Content = new StreamContent(stream);
                response.Content.Headers.ContentType        = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf");
                response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                {
                    FileName = "RegistroClinico.pdf"
                };
            }
            catch (Exception ex)
            {
                // response.State = false;
                //  response.Message = ex.Message;
            }

            return(response);
        }