//[EnableCors(origins: "*", headers: "*", methods: "*")] public ActionResult Novedadpdf(long numregistro, long tokenuserid) { try { string result = System.IO.Path.GetTempPath(); Console.WriteLine(result); byte[] pdfBytes; MemoryStream stream = new MemoryStream(); //variable para crear en memoria el documento PdfWriter writer = new PdfWriter(stream); //writer.SetCloseStream(true); iText.Kernel.Pdf.PdfDocument pdf = new iText.Kernel.Pdf.PdfDocument(writer); Document document = new Document(pdf, PageSize.A4); document.SetMargins(110, 30, 30, 30); pdf.AddEventHandler(PdfDocumentEvent.END_PAGE, new ArchivosPDFNovedadEventHandler()); //LETRAS //iText.IO.Font.FontProgram letra = iText.IO.Font.FontProgram. PdfFont letraNormal = PdfFontFactory.CreateFont("Helvetica"); PdfFont letraNegrilla = PdfFontFactory.CreateFont("Helvetica-Bold"); //COLORES Color colorAprobado = new DeviceRgb(237, 255, 237); Color colorRechazado = new DeviceRgb(255, 237, 237); Color colorHeaderPrincipal = new DeviceRgb(150, 150, 150); Color colorHeaderSecundario = new DeviceRgb(200, 200, 200); Color colorLetraEncabezado = new DeviceRgb(255, 255, 255); Color colorLetraPrincipal = new DeviceRgb(0, 0, 0); //Hora y Fecha Paragraph p = new Paragraph(string.Format("{0:dd/MM/yyyy hh:mm tt}, Bogotá D.C.", DateTime.Now)) .SetFont(letraNormal).SetFontSize(8).SetTextAlignment(TextAlignment.RIGHT); document.Add(p); //Titulo p = new Paragraph(string.Format("ACTA DE VALIDACIÓN - REPORTE NO ATENCIONES")) .SetFont(letraNegrilla).SetFontSize(14).SetTextAlignment(TextAlignment.CENTER); document.Add(p); p = new Paragraph(string.Format("Apreciado prestador,\n")) .SetFont(letraNormal).SetFontSize(10).SetTextAlignment(TextAlignment.JUSTIFIED); document.Add(p); p = new Paragraph(string.Format("{0}:", db.Web_Usuario.Where(u => u.usuario_id == tokenuserid).Select(x => string.Concat(x.razon_social.ToUpper())).FirstOrDefault())) .SetFont(letraNegrilla).SetFontSize(10).SetTextAlignment(TextAlignment.JUSTIFIED); document.Add(p); // p = new Paragraph(string.Format("Se informa que su reporte de No Atenciones RIPS fue APROBADO con el número de registro {0} en la fecha {1} " + "A continuación se resumen los datos del prestador que reporto estas No Atenciones, así como la información general del registro:", numregistro, string.Format("{0:dd/MM/yyyy hh:mm tt}", db.Web_Novedad.Where(n => n.novedad_id == numregistro).Select(x => x.fecha_modificacion).FirstOrDefault()))) .SetFont(letraNormal).SetFontSize(10).SetTextAlignment(TextAlignment.JUSTIFIED); document.Add(p); //Tabla de información del prestador float[] anchoColumnas; anchoColumnas = new float[] { 3, 4 }; Table tablaPrestador = new Table(UnitValue.CreatePercentArray(anchoColumnas)).SetWidth(UnitValue.CreatePercentValue(60)).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER); tablaPrestador.SetMarginTop(10); tablaPrestador.SetMarginBottom(10); Cell cell = new Cell(1, 2) .Add(new Paragraph("Información del prestador:")) .SetFont(letraNegrilla).SetFontSize(10).SetTextAlignment(TextAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE) .SetFontColor(colorLetraEncabezado).SetBackgroundColor(colorHeaderPrincipal, 0.9f) .SetBorder(Border.NO_BORDER); tablaPrestador.AddHeaderCell(cell); // variable codigoprestador var codprestador = db.Web_Usuario.Where(u => u.usuario_id == tokenuserid).Select(x => x.Prestador.codigo).FirstOrDefault(); tablaPrestador.AddCell(CrearCelda("key", "Código del prestador:")); tablaPrestador.AddCell(CrearCelda("value", string.Format("{0}", codprestador))); tablaPrestador.AddCell(CrearCelda("key", "Nombre del prestador:")); tablaPrestador.AddCell(CrearCelda("value", string.Format("{0}", db.Web_Usuario.Where(u => u.usuario_id == tokenuserid).Select(x => x.razon_social).FirstOrDefault()))); tablaPrestador.AddCell(CrearCelda("key", "Email del prestador:")); tablaPrestador.AddCell(CrearCelda("value", string.Format("{0}", db.Web_Usuario.Where(u => u.usuario_id == tokenuserid).Select(x => x.correo).FirstOrDefault()))); document.Add(tablaPrestador); //log.Warn(string.Format("se adiciono tabla del prestador")); //Tabla de información preradicacion anchoColumnas = new float[] { 4, 4 }; Table tablaPrerradicacion = new Table(UnitValue.CreatePercentArray(anchoColumnas)).SetWidth(UnitValue.CreatePercentValue(100)); cell = new Cell(1, 2) .Add(new Paragraph("Información de Reporte:")) .SetFont(letraNegrilla).SetFontSize(10).SetTextAlignment(TextAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE) .SetFontColor(colorLetraEncabezado).SetBackgroundColor(colorHeaderPrincipal, 0.9f) .SetBorder(Border.NO_BORDER); tablaPrerradicacion.AddHeaderCell(cell); tablaPrerradicacion.AddCell(CrearCelda("key", "Fecha de inicio del reporte:")); tablaPrerradicacion.AddCell(CrearCelda("value", string.Format("{0:dd/MM/yyyy}", db.Web_Novedad.Where(n => n.novedad_id == numregistro).Select(x => x.periodofechainicio).FirstOrDefault()))); tablaPrerradicacion.AddCell(CrearCelda("key", "Fecha de fin del reporte:")); tablaPrerradicacion.AddCell(CrearCelda("value", string.Format("{0:dd/MM/yyyy}", db.Web_Novedad.Where(n => n.novedad_id == numregistro).Select(x => x.periodofechafin).FirstOrDefault()))); tablaPrerradicacion.AddCell(CrearCelda("key", "Usuarios:")); tablaPrerradicacion.AddCell(CrearCelda("value", string.Format("{0}", db.Web_Novedad.Where(u => u.FK_web_novedad_web_usuario == tokenuserid).Select(x => x.Web_Tipo_Novedad.nombre).FirstOrDefault()))); //Tabla de información radicacion anchoColumnas = new float[] { 4, 4 }; Table tablaRadicacion = new Table(UnitValue.CreatePercentArray(anchoColumnas)).SetWidth(UnitValue.CreatePercentValue(100)); cell = new Cell(1, 2) .Add(new Paragraph("Información de Acta:")) .SetFont(letraNegrilla).SetFontSize(10).SetTextAlignment(TextAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE) .SetFontColor(colorLetraEncabezado).SetBackgroundColor(colorHeaderPrincipal, 0.9f) .SetBorder(Border.NO_BORDER); tablaRadicacion.AddHeaderCell(cell); tablaRadicacion.AddCell(CrearCelda("key", "# REGISTRO:")); tablaRadicacion.AddCell(CrearCelda("value", string.Format("{0}", numregistro))); tablaRadicacion.AddCell(CrearCelda("key", "Fecha de radicación:")); tablaRadicacion.AddCell(CrearCelda("value", string.Format("{0:dd/MM/yyyy hh:mm tt}", db.Web_Novedad.Where(n => n.novedad_id == numregistro).Select(x => x.fecha_modificacion).FirstOrDefault()))); //Insertar tablas de prerradicación y radicación anchoColumnas = new float[] { 10, 1, 10 }; Table tablaInformacion = new Table(UnitValue.CreatePercentArray(anchoColumnas)).SetWidth(UnitValue.CreatePercentValue(100)); tablaInformacion.SetMarginTop(10); tablaInformacion.SetMarginBottom(10); cell = new Cell() .Add(tablaPrerradicacion) .SetBorder(Border.NO_BORDER); tablaInformacion.AddCell(cell); tablaInformacion.AddCell(new Cell().SetBorder(Border.NO_BORDER)); cell = new Cell() .Add(tablaRadicacion) .SetBorder(Border.NO_BORDER); tablaInformacion.AddCell(cell); document.Add(tablaInformacion); p = new Paragraph(string.Format("A continuación se indica el número de registros cargados para cada estructura:")) .SetFont(letraNormal).SetFontSize(10).SetTextAlignment(TextAlignment.JUSTIFIED); document.Add(p); //Tabla de registros cargados anchoColumnas = new float[] { 1, 1, 1, 1, 1, 1, 1, 1, 1 }; Table tablaEstructuras = new Table(UnitValue.CreatePercentArray(anchoColumnas)).SetWidth(UnitValue.CreatePercentValue(100)); tablaEstructuras.SetMarginTop(10); tablaEstructuras.SetMarginBottom(10); cell = new Cell(1, 9) .Add(new Paragraph("Registros cargados por estructura")) .SetFont(letraNegrilla).SetFontSize(10).SetTextAlignment(TextAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE) .SetFontColor(colorLetraEncabezado).SetBackgroundColor(colorHeaderPrincipal, 0.9f) .SetBorder(Border.NO_BORDER); tablaEstructuras.AddHeaderCell(cell); //Header secundario foreach (var estructura in db.Estructura) { cell = new Cell() .Add(new Paragraph(estructura.acronimo)) .SetFont(letraNegrilla).SetFontSize(8).SetTextAlignment(TextAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE) .SetFontColor(colorLetraPrincipal).SetBackgroundColor(colorHeaderSecundario, 0.9f) .SetBorder(Border.NO_BORDER); tablaEstructuras.AddHeaderCell(cell); } DataTable facturas = null; //Cantidad de registros foreach (var estructura in db.Estructura) { int cantidad = 0; tablaEstructuras.AddCell(CrearCelda("value", cantidad.ToString())); } document.Add(tablaEstructuras); p = new Paragraph(string.Format("Secretaría Distrital de Salud de Bogotá - Dirección de Planeación Sectorial \nPor favor conserve sus archivos en caso de ser requeridos por la entidad")) .SetFont(letraNormal).SetFontSize(10).SetTextAlignment(TextAlignment.CENTER); document.Add(p); document.Close(); pdfBytes = stream.ToArray(); return(File(pdfBytes, "application/pdf", String.Concat("NoAtencion-Rad", numregistro, "_", string.Format("{0}", codprestador), ".pdf"))); } catch (Exception e) { LogsController log = new LogsController(e.ToString()); log.createFolder(); //Envio mensaje de Error a la Vista throw new HttpException(404, "HTTP/1.1 404 Not Found"); } }