public IArchivoReporte CrearArchivoReporteFactoria(int tipoReporte, AufenPortalReportesDataContext db, EMPRESA empresa, vw_Ubicacione departamento, DateTime FechaDesde, DateTime FechaHasta, string path, string rut) { IArchivoReporte archivoReporte = null; string buff = null; if (!String.IsNullOrEmpty(rut)) { buff = ("000000000" + rut.Trim()).Substring(("000000000" + rut.Trim()).Length - 9, 9); } switch (tipoReporte) { case TipoReporte.LibroAtrasos: archivoReporte = new LibroAtrasos(db, empresa, departamento, FechaDesde, FechaHasta, path, buff); break; case TipoReporte.AsistenciaLegal: archivoReporte = new AsistenciaLegal(db, empresa, departamento, FechaDesde, FechaHasta, path, buff); break; case TipoReporte.LibroSobreTiempo: archivoReporte = new LibroSobreTiempo(db, empresa, departamento, FechaDesde, FechaHasta, path, buff); break; case TipoReporte.AsistenciaPersonal: archivoReporte = new AsistenciaPersonal(db, empresa, departamento, FechaDesde, FechaHasta, path, buff); break; case TipoReporte.Ausencia: archivoReporte = new Ausencia(db, empresa, departamento, FechaDesde, FechaHasta, path, buff); break; } return archivoReporte; }
public LibroAtrasos(AufenPortalReportesDataContext db, EMPRESA empresa, vw_Ubicacione departamento, DateTime FechaDesde, DateTime FechaHasta, string path, string rut) { //Nombre del archivo y ubiación en el árbol de carpetas NombreArchivo = String.Format("{0}/{1}/LibroAtrasos.pdf", empresa.Descripcion, departamento.Descripcion); // Vamos a buscar los datos que nos permitirtán armar elreporte IEnumerable<sp_LibroAsistenciaResult> resultadoLibroAtrasos = db.sp_LibroAsistencia( FechaDesde.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture), FechaHasta.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture), int.Parse(empresa.Codigo).ToString(), departamento.Codigo, rut).ToList(); IEnumerable<LibroAsistenciaDTO> libroAtrasos = Mapper.Map<IEnumerable<sp_LibroAsistenciaResult>, IEnumerable<LibroAsistenciaDTO>>(resultadoLibroAtrasos) .Where(x =>x.Entrada.HasValue && x.Salida.HasValue && x.SalidaTeorica.HasValue && x.EntradaTeorica.HasValue && x.Entrada > x.EntradaTeorica); // Comenzaremos a crear el reporte if (libroAtrasos.Any()) { Configuracion(); Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 50, 35); using (var ms = new MemoryStream()) { PdfWriter pdfWriter = PdfWriter.GetInstance(doc, ms); pdfWriter.PageEvent = new Header(empresa, path); doc.Open(); foreach (var reporte in libroAtrasos.GroupBy(x => new { x.Rut, x.IdDepartamento, x.IdEmpresa })) { var empleado = db.vw_Empleados.FirstOrDefault(x => x.IdEmpresa == empresa.Codigo && x.IdUbicacion == reporte.Key.IdDepartamento && x.Codigo == reporte.Key.Rut); if (empleado == null) { empleado = new vw_Empleado(); } doc.AddAuthor("Aufen"); doc.AddCreationDate(); doc.AddCreator("Aufen"); doc.AddTitle("Libro de Atrasos"); // Texto Paragraph parrafo = new Paragraph(); parrafo.Add(new Paragraph( String.Format("Departamento: {1}, Fecha de Reporte: {0}", DateTime.Now.ToShortDateString(), departamento.SucursalPlanta), Normal) { Alignment = Element.ALIGN_CENTER }); parrafo.Add(new Paragraph("Informe de Atrasos por Área", Titulo) { Alignment = Element.ALIGN_CENTER }); doc.Add(parrafo); doc.Add(new Phrase()); doc.Add(new Phrase()); PdfPTable informacionPersonal = new PdfPTable(new float[] { 1,5}); informacionPersonal.AddCell(new PdfPCell(new Phrase("Rut:", Normal))); informacionPersonal.AddCell(new PdfPCell(new Phrase(empleado.RutAufen, NormalNegrita))); informacionPersonal.AddCell(new PdfPCell(new Phrase("Nombre:", Normal))); informacionPersonal.AddCell(new PdfPCell(new Phrase(empleado.NombreCompleto, NormalNegrita))); informacionPersonal.AddCell(new PdfPCell(new Phrase("Centro de Costos:", Normal))); informacionPersonal.AddCell(new PdfPCell(new Phrase(String.Empty, NormalNegrita))); doc.Add(new Phrase()); doc.Add(informacionPersonal); // tabla PdfPTable tabla = new PdfPTable(new float[] {2, 2, 2, 2, 2, 2, 2, 4 }); // Primera lìnea cabecera tabla.AddCell(new PdfPCell(new Phrase("Fecha", Chico)) { Rowspan = 2 }); //tabla.AddCell(new PdfPCell(new Phrase("Empleado", Chico)) { Colspan = 3 }); tabla.AddCell(new PdfPCell(new Phrase("Horario", Chico)) { Colspan = 2 }); tabla.AddCell(new PdfPCell(new Phrase("Marcas", Chico)) { Colspan = 2 }); tabla.AddCell(new PdfPCell(new Phrase("Horas Trabajadas", Chico)) { Colspan = 2 }); tabla.AddCell(new PdfPCell(new Phrase("Autorizaciones", Chico))); // Segunda lìnea cabecera //tabla.AddCell(new PdfPCell(new Phrase("Rut", Chico))); //tabla.AddCell(new PdfPCell(new Phrase("Apellidos", Chico))); //tabla.AddCell(new PdfPCell(new Phrase("Nombres", Chico))); tabla.AddCell(new PdfPCell(new Phrase("Ing.", Chico))); tabla.AddCell(new PdfPCell(new Phrase("Sal.", Chico))); tabla.AddCell(new PdfPCell(new Phrase("Ing.", Chico))); tabla.AddCell(new PdfPCell(new Phrase("Sal.", Chico))); tabla.AddCell(new PdfPCell(new Phrase("Atrasos", Chico))); tabla.AddCell(new PdfPCell(new Phrase("H.T.N.", Chico))); tabla.AddCell(new PdfPCell(new Phrase("Permisos", Chico))); foreach (var atraso in reporte) { TimeSpan tiempoAtraso = (atraso.Salida.HasValue && atraso.Entrada.HasValue ? atraso.Salida.Value.Subtract(atraso.Entrada.Value) : new TimeSpan(0)) - (atraso.SalidaTeorica.HasValue && atraso.EntradaTeorica.HasValue ? atraso.SalidaTeorica.Value.Subtract(atraso.EntradaTeorica.Value) : new TimeSpan(0)); TimeSpan tiempoNormal = atraso.SalidaTeorica.HasValue && atraso.EntradaTeorica.HasValue ? atraso.SalidaTeorica.Value.Subtract(atraso.EntradaTeorica.Value) : new TimeSpan(0); tabla.AddCell(new PdfPCell(new Phrase(atraso.Fecha.Value.ToString("ddd dd/MM"), Chico)) { HorizontalAlignment = Element.ALIGN_LEFT }); //tabla.AddCell(new PdfPCell(new Phrase(atraso.Rut.ToStringConGuion(), Chico))); //tabla.AddCell(new PdfPCell(new Phrase(atraso.Apellidos, Chico))); //tabla.AddCell(new PdfPCell(new Phrase(atraso.Nombres, Chico))); tabla.AddCell(new PdfPCell(new Phrase(atraso.Entrada.HasValue ? atraso.Entrada.Value.ToString("HH:mm") : String.Empty, Chico))); tabla.AddCell(new PdfPCell(new Phrase(atraso.Salida.HasValue ? atraso.Salida.Value.ToString("HH:mm") : String.Empty, Chico))); tabla.AddCell(new PdfPCell(new Phrase(atraso.EntradaTeorica.HasValue ? atraso.EntradaTeorica.Value.ToString("HH:mm") : String.Empty, Chico))); tabla.AddCell(new PdfPCell(new Phrase(atraso.SalidaTeorica.HasValue ? atraso.SalidaTeorica.Value.ToString("HH:mm") : String.Empty, Chico))); tabla.AddCell(new PdfPCell(new Phrase(atraso.printAtraso, Chico))); tabla.AddCell(new PdfPCell(new Phrase("", Chico))); tabla.AddCell(new PdfPCell(new Phrase(atraso.Observacion, Chico))); } tabla.AddCell(new PdfPCell(new Phrase("Total", ChicoNegrita)) { Colspan=5 }); //TODO: aqí va la suma de astrasos tabla.AddCell(new PdfPCell(new Phrase(reporte.CalculaAtrasoEntrada(), Chico))); //TODO: aqí va la suma de H.T.N. tabla.AddCell(new PdfPCell(new Phrase("", Chico))); tabla.AddCell(new PdfPCell(new Phrase("", Chico))); doc.Add(tabla); doc.NewPage(); } doc.Close(); _Archivo = ms.ToArray(); } } }
public AsistenciaLegal(AufenPortalReportesDataContext db, EMPRESA empresa, vw_Ubicacione departamento, DateTime FechaDesde, DateTime FechaHasta, string path, string rut) { // Vamos a buscar los datos que nos permitirtán armar elreporte NombreArchivo = String.Format("{0}/{1}/LibroAtrasos.pdf", empresa.Descripcion, departamento.Descripcion); //Resultado de marcas IEnumerable<sp_LibroAsistenciaResult> resultadoLibroAtrasos = db.sp_LibroAsistencia( FechaDesde.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture), FechaHasta.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture), int.Parse(empresa.Codigo).ToString(), departamento.Codigo, rut).ToList(); IEnumerable<LibroAsistenciaDTO> resultado = Mapper.Map<IEnumerable<sp_LibroAsistenciaResult>, IEnumerable<LibroAsistenciaDTO>>(resultadoLibroAtrasos); // Resumen de inasistencias IEnumerable<sp_LibroInasistenciaResult> resultadoLibroInasistencias = db.sp_LibroInasistencia(FechaDesde.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture) , FechaHasta.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture) , int.Parse(empresa.Codigo).ToString() , departamento.Codigo , rut); IEnumerable<LibroInasistenciaDTO> resultadoInasistencia = Mapper.Map<IEnumerable<sp_LibroInasistenciaResult>, IEnumerable<LibroInasistenciaDTO>>(resultadoLibroInasistencias); if (resultadoLibroAtrasos.Any()) { string[] diasSemana = new[] { "dom", "lun", "mar", "mie", "ju", "vie", "sab" }; using (MemoryStream finalStream = new MemoryStream()) { PdfCopyFields copy = new PdfCopyFields(finalStream); foreach (var reporte in resultado.Where(x => x.Rut != null).GroupBy(x => new { x.Rut, x.IdEmpresa, x.IdDepartamento, Mes = x.Fecha.Value.Month, Anio = x.Fecha.Value.Year })) { var inasistencias = resultadoInasistencia.Where(x => x.Rut!= null && x.Rut == reporte.Key.Rut && x.IdEmpresa == reporte.Key.IdEmpresa && x.IdDepartamento == reporte.Key.IdDepartamento && reporte.Key.Mes == x.Fecha.Value.Month && reporte.Key.Anio == x.Fecha.Value.Year); var empleado = db.vw_Empleados.FirstOrDefault(x => x.IdEmpresa == empresa.Codigo && x.IdUbicacion == reporte.Key.IdDepartamento && x.Codigo == reporte.Key.Rut); int numeroSemanas = reporte.Max(x => x.NumSemana) == 6 ? 6 : 5; using (MemoryStream ms = new MemoryStream()) { using (PdfReader pdfReader = new PdfReader(path + String.Format(@"\ReporteAsistenciaLegal{0}.pdf", numeroSemanas))) { DateTime fechaReferencia = reporte.First().Fecha.Value; DateTime primerDiaMes = new DateTime(fechaReferencia.Year, fechaReferencia.Month, 1); DateTime ultimoDiaMes = primerDiaMes.AddMonths(1).AddSeconds(-1); PdfStamper pdfStamper = new PdfStamper(pdfReader, ms); int PageCount = pdfReader.NumberOfPages; for (int x = 1; x <= PageCount; x++) { PdfContentByte cb = pdfStamper.GetOverContent(x); Image imagen = Image.GetInstance(String.Format(@"{0}\imagenes\LogosEmpresas\logo{1}.jpg", path, empresa.Codigo.Trim())); imagen.ScaleToFit(100, 200); imagen.SetAbsolutePosition(450, 750); cb.AddImage(imagen); } pdfStamper.AcroFields.SetField("Mes", new DateTime(reporte.Key.Anio, reporte.Key.Mes, 1).ToString("yyyy MMM")); pdfStamper.AcroFields.SetField("Nombre", empleado != null ? empleado.NombreCompleto : String.Empty); pdfStamper.AcroFields.SetField("Rut", empleado.RutAufen); pdfStamper.AcroFields.SetField("Departamento", String.Format("{0} ({1})", departamento!= null ? departamento.SucursalPlanta : String.Empty, empresa!=null ? empresa.Descripcion.Trim() : String.Empty)); pdfStamper.AcroFields.SetField("Fecha", String.Format("{0} - {1}", primerDiaMes.ToShortDateString(), ultimoDiaMes.ToShortDateString())); pdfStamper.AcroFields.SetField("ImpresoPagina1", DateTime.Now.ToShortDateString()); pdfStamper.AcroFields.SetField("ImpresoPagina2", DateTime.Now.ToShortDateString()); pdfStamper.AcroFields.SetField("UsuarioPagina1", ""); pdfStamper.AcroFields.SetField("UsuarioPagina2", ""); //Para todas las semanas for (int i = 1; i <= numeroSemanas; i++) { //Para todos los días de la semana var semana = reporte.Where(x => x.NumSemana == i); for (int j = 0; j <= 6; j++) { // Si se elimina esto el domingo va aquedar al final int correccionDia = j;//j == 6 ? 0 : j + 1; var dia = reporte.FirstOrDefault(x => x.NumSemana == i && (int)x.Fecha.Value.DayOfWeek == j); // pdfStamper.AcroFields.SetField(String.Format("Semana{0}Tipo{1}", i, correccionDia), String.Format("{0}\n{1}", String.Format("{0}-{1}", dia!= null && dia.Entrada.HasValue ? dia.Entrada.Value.ToString("HH:mm") : String.Empty , dia!=null && dia.Salida.HasValue ? dia.Salida.Value.ToString("HH:mm") : String.Empty), dia != null ? dia.Observacion : String.Empty)); pdfStamper.AcroFields.SetField(String.Format("Semana{0}Dia{1}", i, correccionDia), String.Format("{0} {1}", dia != null ? dia.Fecha.Value.ToString("dd/MM") : string.Empty, diasSemana[j])); } // Semana a semana pdfStamper.AcroFields.SetField(String.Format("Semana{0}Jornada", i), semana.CalculaJornada()); pdfStamper.AcroFields.SetField(String.Format("Semana{0}Asistencia", i), semana.CalculaAsistencia()); // T. de Salida = inasistencia justifica pdfStamper.AcroFields.SetField(String.Format("Semana{0}Salidas", i), semana.CalculaInasistenciaJustificadaLegal()); // T. de Ausencia = inasistencia INjustificada //var inasistenciaSemanal = inasistencias.Where(x => x.Fecha.HasValue && x.Fecha.Value.Day >= (i - 1) * 7 && x.Fecha.Value.Day <= i * 7); pdfStamper.AcroFields.SetField(String.Format("Semana{0}Ausencias", i), semana.CalculaInasistenciaInjustificadaLegal()); pdfStamper.AcroFields.SetField(String.Format("Semana{0}AtrasosSalidas", i), semana.CalculaAtrasoSalida()); pdfStamper.AcroFields.SetField(String.Format("Semana{0}NumeroAtrasos", i), semana.CalculaDiasAtraso()); pdfStamper.AcroFields.SetField(String.Format("Semana{0}NumeroSalidas", i), semana.CalculaDiasSalidaAdelantada()); pdfStamper.AcroFields.SetField(String.Format("Semana{0}ExtraConTurno", i), semana.CalculaHorasExtra()); //pdfStamper.AcroFields.SetField(String.Format("Semana{0}ExtraSinTurno", i), ""); } // Resumen de todas las semanas pdfStamper.AcroFields.SetField("ResumenJornada", reporte.CalculaJornada()); pdfStamper.AcroFields.SetField("ResumenAsistencia", reporte.CalculaAsistencia()); pdfStamper.AcroFields.SetField("ResumenSalidas", reporte.CalculaInasistenciaJustificadaLegal()); pdfStamper.AcroFields.SetField("ResumenAusencias", reporte.CalculaInasistenciaInjustificadaLegal()); pdfStamper.AcroFields.SetField("ResumenAtrasosSalidas", reporte.CalculaAtrasoEntrada()); pdfStamper.AcroFields.SetField("ResumenNumeroAtrasos", reporte.CalculaDiasAtraso()); pdfStamper.AcroFields.SetField("ResumenNumeroSalidas", reporte.CalculaDiasSalidaAdelantada()); pdfStamper.AcroFields.SetField("ResumenExtraConTurno", reporte.CalculaHorasExtra()); //pdfStamper.AcroFields.SetField("ResumenExtraSinTurno", ""); pdfStamper.Writer.CloseStream = false; pdfStamper.FormFlattening = true; pdfStamper.Close(); ms.Position = 0; copy.AddDocument(new PdfReader(ms)); ms.Dispose(); } } } copy.Close(); _Archivo = finalStream.ToArray(); } } }
public Ausencia(AufenPortalReportesDataContext db, EMPRESA empresa, vw_Ubicacione departamento, DateTime FechaDesde, DateTime FechaHasta, string path, string rut) { //Nombre del archivo y ubiación en el árbol de carpetas NombreArchivo = String.Format("{0}/{1}/PersonalAusente.pdf", empresa.Descripcion, departamento.Descripcion); // Vamos a buscar los datos que nos permitirtán armar elreporte IEnumerable<sp_LibroInasistenciaResult> resultado = db.sp_LibroInasistencia( FechaDesde.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture) , FechaHasta.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture) , int.Parse(empresa.Codigo).ToString() , departamento.Codigo , rut).OrderBy(x => x.Fecha).ToList(); IEnumerable<LibroInasistenciaDTO> inasistencias = Mapper.Map<IEnumerable<sp_LibroInasistenciaResult>, IEnumerable<LibroInasistenciaDTO>>(resultado); if (inasistencias.Any()) { Configuracion(); Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 50, 35); using (var ms = new MemoryStream()) { PdfWriter pdfWriter = PdfWriter.GetInstance(doc, ms); pdfWriter.PageEvent = new Header(empresa, path); doc.Open(); foreach (var reporte in inasistencias.Where(x=>x.Rut!=null).GroupBy(x => new { x.Rut, x.IdDepartamento, x.IdEmpresa }).Take(3)) { doc.AddAuthor("Aufen"); doc.AddCreationDate(); doc.AddCreator("Aufen"); doc.AddTitle("Informe de Personal Ausente (sin marcas)"); Paragraph parrafo = new Paragraph(); parrafo.Add(new Paragraph("Informe de Personal Ausente (sin marcas)", Titulo) { Alignment = Element.ALIGN_CENTER }); parrafo.Add(new Paragraph(String.Format("Período: {0} a {1}", FechaDesde.ToShortDateString(), FechaHasta.ToShortDateString()), Normal) { Alignment = Element.ALIGN_CENTER }); parrafo.Add(new Paragraph("Centro de Costos:", Normal)); doc.Add(parrafo); doc.Add(new Phrase()); PdfPTable tabla = new PdfPTable(new float[] {2, 2, 2, 2, 1, 1, 4 }); // Encabezado tabla.AddCell(new PdfPCell(new Phrase("Empleado", Normal)) { Colspan = 4}); tabla.AddCell(new PdfPCell(new Phrase("Horario", Normal)) { Colspan = 2 }); tabla.AddCell(new PdfPCell(new Phrase("Autorizaciones", Normal))); // 2 encabezado tabla.AddCell(new PdfPCell(new Phrase("Fecha", Chico))); tabla.AddCell(new PdfPCell(new Phrase("Rut", Chico))); tabla.AddCell(new PdfPCell(new Phrase("Apellidos", Chico))); tabla.AddCell(new PdfPCell(new Phrase("Nombres", Chico))); tabla.AddCell(new PdfPCell(new Phrase("Ing.", Chico))); tabla.AddCell(new PdfPCell(new Phrase("Sal.", Chico))); tabla.AddCell(new PdfPCell(new Phrase("Autorizaciones", Chico))); var empleado = db.vw_Empleados.FirstOrDefault(x => x.IdEmpresa == empresa.Codigo && x.IdUbicacion == reporte.Key.IdDepartamento && x.Codigo == reporte.Key.Rut); foreach(var ausencia in reporte) { //Fecha tabla.AddCell(new PdfPCell(new Phrase(ausencia.Fecha.HasValue ? ausencia.Fecha.Value.ToString("ddd dd/MM") : String.Empty, Chico))); //Código tabla.AddCell(new PdfPCell(new Phrase(empleado.RutAufen, Chico))); //Apellidos tabla.AddCell(new PdfPCell(new Phrase((ausencia.Apellidos ?? string.Empty).Trim(), Chico))); //Nombres tabla.AddCell(new PdfPCell(new Phrase((ausencia.Nombres ?? string.Empty).Trim(), Chico))); //Ing. tabla.AddCell(new PdfPCell(new Phrase(ausencia.EntradaTeorica.HasValue ? ausencia.EntradaTeorica.Value.ToString("HH:mm") : String.Empty, Chico))); //Sal. tabla.AddCell(new PdfPCell(new Phrase(ausencia.SalidaTeorica.HasValue ? ausencia.SalidaTeorica.Value.ToString("HH:mm") : String.Empty, Chico))); //Autorizaciones tabla.AddCell(new PdfPCell(new Phrase(ausencia.Observacion, Chico))); } doc.Add(tabla); doc.NewPage(); } doc.Close(); _Archivo = ms.ToArray(); } } }
public AsistenciaPersonal(AufenPortalReportesDataContext db, EMPRESA empresa, vw_Ubicacione departamento, DateTime FechaDesde, DateTime FechaHasta, string path, string rut) { //Nombre del archivo y ubiación en el árbol de carpetas NombreArchivo = String.Format("{0}/{1}/AsistenciaPersonal.pdf", empresa.Descripcion, departamento.Descripcion); // Vamos a buscar los datos que nos permitirtán armar elreporte IEnumerable<sp_LibroAsistenciaResult> resultado = db.sp_LibroAsistencia( FechaDesde.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture), FechaHasta.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture), int.Parse(empresa.Codigo).ToString(), departamento.Codigo, rut).ToList(); IEnumerable<LibroAsistenciaDTO> libroAsistencia = Mapper.Map<IEnumerable<sp_LibroAsistenciaResult>, IEnumerable<LibroAsistenciaDTO>>(resultado); if (libroAsistencia.Any()) { Configuracion(); Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 50, 35); using (var ms = new MemoryStream()) { PdfWriter pdfWriter = PdfWriter.GetInstance(doc, ms); pdfWriter.PageEvent = new Header(empresa, path); doc.Open(); foreach (var reporte in libroAsistencia.Where(x => x.Rut != null).GroupBy(x => new { x.Rut, x.IdDepartamento, x.IdEmpresa })) { var empleado = db.vw_Empleados.FirstOrDefault(x => x.IdEmpresa == empresa.Codigo && x.IdUbicacion == reporte.Key.IdDepartamento && x.Codigo == reporte.Key.Rut); if (empleado == null) { empleado = new vw_Empleado(); } doc.AddAuthor("Aufen"); doc.AddCreationDate(); doc.AddCreator("Aufen"); doc.AddTitle("Libro de Asistencia Personal"); Paragraph parrafo = new Paragraph(); parrafo.Add(new Paragraph("Asistencia Personal", Titulo) { Alignment = Element.ALIGN_CENTER }); doc.Add(parrafo); // Texto PdfPTable tablaEncabezado = new PdfPTable(new float[] { 1, 5, 1, 5 }); tablaEncabezado.AddCell(new PdfPCell(new Phrase("Nombre:", Chico)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(empleado.NombreCompleto, Normal)) { Border = Rectangle.NO_BORDER, Colspan=3 }); tablaEncabezado.AddCell(new PdfPCell(new Phrase("Empresa:", Chico)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(empresa != null ? empresa.Descripcion.Trim() : String.Empty, Normal)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase("Rut:", Chico)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(empleado.RutAufen, Normal)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase("Sucursal o Planta:", Chico)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(empleado.SucursalPlanta, Normal)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase("Cargo:", Chico)) { Border = Rectangle.NO_BORDER }); //tablaEncabezado.AddCell(new PdfPCell(new Phrase(empleado.Cargo, Normal)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(String.Empty, Normal)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase("Centro de Costo:", Chico)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(String.Empty, Normal)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(String.Empty, Normal)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(String.Empty, Normal)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(String.Format("PERIODO: {0} a {1}", FechaDesde.ToShortDateString(), FechaHasta.ToShortDateString()), Normal)) { Colspan = 4, Border = Rectangle.NO_BORDER }); doc.Add(new Paragraph(" ")); tablaEncabezado.AddCell(new PdfPCell(GetNomenclatura()) { Colspan = 4 }); doc.Add(tablaEncabezado); doc.Add(new Phrase()); doc.Add(new Phrase()); // tabla PdfPTable tabla = new PdfPTable(new float[] { 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4 }); // Primera lìnea cabecera tabla.AddCell(new PdfPCell(new Phrase("Fecha", Chico))); tabla.AddCell(new PdfPCell(new Phrase("HI", Chico)) { }); tabla.AddCell(new PdfPCell(new Phrase("HS", Chico))); tabla.AddCell(new PdfPCell(new Phrase("HCol", Chico))); tabla.AddCell(new PdfPCell(new Phrase("MI", Chico))); tabla.AddCell(new PdfPCell(new Phrase("MS", Chico))); tabla.AddCell(new PdfPCell(new Phrase("HTH", Chico))); tabla.AddCell(new PdfPCell(new Phrase("HTN", Chico))); tabla.AddCell(new PdfPCell(new Phrase("HE", Chico))); tabla.AddCell(new PdfPCell(new Phrase("ATR", Chico))); tabla.AddCell(new PdfPCell(new Phrase("ADL", Chico))); tabla.AddCell(new PdfPCell(new Phrase("Col.", Chico))); tabla.AddCell(new PdfPCell(new Phrase("S.Ent", Chico))); tabla.AddCell(new PdfPCell(new Phrase("Permisos", Chico))); foreach (var atraso in reporte) { //Fecha tabla.AddCell(new PdfPCell(new Phrase(atraso.Fecha.Value.ToString("ddd dd/MM"), Chico))); //Hora Ingreso tabla.AddCell(new PdfPCell(new Phrase(atraso.EntradaTeorica.HasValue ? atraso.EntradaTeorica.Value.ToShortTimeString() : null, Chico))); // Hora Salida tabla.AddCell(new PdfPCell(new Phrase(atraso.SalidaTeorica.HasValue ? atraso.SalidaTeorica.Value.ToShortTimeString() : null, Chico))); // Colaciòn por turno tabla.AddCell(new PdfPCell(new Phrase((int)atraso.TiempoColacion.Value.TotalHours + atraso.TiempoColacion.Value.ToString(@"\:mm"), Chico))); // Marca de entrada tabla.AddCell(new PdfPCell(new Phrase(atraso.Entrada.HasValue ? atraso.Entrada.Value.ToShortTimeString() : null, Chico))); // Marca de salida tabla.AddCell(new PdfPCell(new Phrase(atraso.Salida.HasValue ? atraso.Salida.Value.ToShortTimeString() : null, Chico))); //Horas pactadas po hombre tabla.AddCell(new PdfPCell(new Phrase(atraso.printHorasPactadas, Chico))); //Horas realizadas tabla.AddCell(new PdfPCell(new Phrase(atraso.printHorasReales.ToString(), Chico))); //Horas extra tabla.AddCell(new PdfPCell(new Phrase(atraso.printHorasExtra, Chico))); // Atraso tabla.AddCell(new PdfPCell(new Phrase(atraso.printAtraso, Chico))); // Salida adelantada tabla.AddCell(new PdfPCell(new Phrase(atraso.printSalidaAdelantada, Chico))); // Colación tabla.AddCell(new PdfPCell(new Phrase(atraso.printTiempoColacionReal, Chico))); // S.Ent tabla.AddCell(new PdfPCell(new Phrase(atraso.printSobreEntrada, Chico))); // Permisos tabla.AddCell(new PdfPCell(new Phrase(atraso.Observacion, Chico))); } //Subtotal tabla.AddCell(new PdfPCell(new Phrase("Sub Total", Chico)) { Colspan = 6 }); //Horas pactadas po hombre tabla.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaJornada(reporte), Chico))); //Horas realizadas tabla.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaAsistencia(reporte), Chico))); //Horas extra tabla.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaHorasExtra(reporte), Chico))); // Atraso tabla.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaAtrasoEntrada(reporte), Chico))); // Salida adelantada tabla.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaSalidaAdelantada(reporte), Chico))); // Colacón tabla.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaColacion(reporte), Chico))); // S.Ent tabla.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaSobreEntrada(reporte), Chico))); // Permisos tabla.AddCell(new PdfPCell(new Phrase("", Chico))); doc.Add(tabla); doc.Add(new Phrase()); // Resumen PdfPTable resumen = new PdfPTable(new float[] { 2, 1, 2, 1, 2, 1, 2, 1 }); //Días Trabajados resumen.AddCell(new PdfPCell(new Phrase("Días Trabajados", Chico)) { Border = Rectangle.NO_BORDER }); resumen.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaDiasTrabajdos(reporte), Chico)) { Border = Rectangle.NO_BORDER }); // resumen.AddCell(new PdfPCell(new Phrase("Horas Pactadas", Chico)) { Border = Rectangle.NO_BORDER }); resumen.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaAsistencia(reporte), Chico)) { Border = Rectangle.NO_BORDER }); // resumen.AddCell(new PdfPCell(new Phrase("Horas extras", Chico)) { Border = Rectangle.NO_BORDER }); resumen.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaHorasExtra(reporte), Chico)) { Border = Rectangle.NO_BORDER }); // resumen.AddCell(new PdfPCell(new Phrase("Errores de marca", Chico)) { Border = Rectangle.NO_BORDER }); resumen.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaErroresMarcaje(reporte), Chico)) { Border = Rectangle.NO_BORDER }); // resumen.AddCell(new PdfPCell(new Phrase("Días ausentes", Chico)) { Border = Rectangle.NO_BORDER }); resumen.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaDiasInasistencias(reporte), Chico)) { Border = Rectangle.NO_BORDER }); // resumen.AddCell(new PdfPCell(new Phrase("Horas Trabajadas", Chico)) { Border = Rectangle.NO_BORDER }); resumen.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaAsistencia(reporte), Chico)) { Border = Rectangle.NO_BORDER }); // resumen.AddCell(new PdfPCell(new Phrase("Vacaciones", Chico)) { Border = Rectangle.NO_BORDER }); resumen.AddCell(new PdfPCell(new Phrase("", Chico)) { Border = Rectangle.NO_BORDER }); // Aquí va una tabla con el espacio para la firma resumen.AddCell(new PdfPCell(new Phrase("", Chico)) { VerticalAlignment = Rectangle.ALIGN_BOTTOM, HorizontalAlignment = Rectangle.ALIGN_CENTER, Colspan = 2, Rowspan = 3, Border = Rectangle.NO_BORDER }); // resumen.AddCell(new PdfPCell(new Phrase("Días Atraso", Chico)) { Border = Rectangle.NO_BORDER }); resumen.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaDiasAtraso(reporte), Chico)) { Border = Rectangle.NO_BORDER }); // resumen.AddCell(new PdfPCell(new Phrase("Total Atraso", Chico)) { Border = Rectangle.NO_BORDER }); resumen.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaAtrasoEntrada(reporte), Chico)) { Border = Rectangle.NO_BORDER }); // resumen.AddCell(new PdfPCell(new Phrase("Licencias Médicas", Chico)) { Border = Rectangle.NO_BORDER }); resumen.AddCell(new PdfPCell(new Phrase("", Chico)) { Border = Rectangle.NO_BORDER }); // resumen.AddCell(new PdfPCell(new Phrase("Salidas", Chico)) { Border = Rectangle.NO_BORDER }); resumen.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaDiasSalidaAdelantada(reporte), Chico)) { Border = Rectangle.NO_BORDER }); // resumen.AddCell(new PdfPCell(new Phrase("Total Salidas", Chico)) { Border = Rectangle.NO_BORDER }); resumen.AddCell(new PdfPCell(new Phrase(LibroAsistenciaDTOHelpers.CalculaSalidaAdelantada(reporte), Chico)) { Border = Rectangle.NO_BORDER }); resumen.AddCell(new PdfPCell(new Phrase("", Chico)) { Border = Rectangle.NO_BORDER }); resumen.AddCell(new PdfPCell(new Phrase("", Chico)) { Border = Rectangle.NO_BORDER }); resumen.AddCell(new PdfPCell(new Phrase(" ", Chico)) { Border = Rectangle.NO_BORDER, Colspan = 8, Rowspan = 5 }); resumen.AddCell(new PdfPCell(new Phrase(" ", Chico)) { Border = Rectangle.NO_BORDER, Colspan = 8 }); resumen.AddCell(new PdfPCell(new Phrase("", Chico)) { Border = Rectangle.NO_BORDER, Colspan = 6 }); resumen.AddCell(new PdfPCell(new Phrase("______________________ Firma Empleado", Chico)) { VerticalAlignment = Rectangle.ALIGN_BOTTOM, HorizontalAlignment = Rectangle.ALIGN_CENTER, Colspan = 2, Border = Rectangle.NO_BORDER }); doc.Add(resumen); //PdfPTable firma = new PdfPTable(new float[] { 2, 1, 2, 1, 2, 1, 2, 1 }); //firma.AddCell(new PdfPCell(new Phrase(" ", Chico)) { Border = Rectangle.NO_BORDER, Colspan = 8, Rowspan = 2 }); ////firma.AddCell(new PdfPCell(new Phrase(" ", Chico)) { Border = Rectangle.NO_BORDER, Colspan = 8 }); //firma.AddCell(new PdfPCell(new Phrase("", Chico)) { Border = Rectangle.NO_BORDER, Colspan = 6 }); //firma.AddCell(new PdfPCell(new Phrase("______________________ Firma Empleado", Chico)) { VerticalAlignment = Rectangle.ALIGN_BOTTOM, HorizontalAlignment = Rectangle.ALIGN_CENTER, Colspan = 2, Border = Rectangle.NO_BORDER, FixedHeight = 1.7f }); //doc.Add(new Phrase()); //doc.Add(new Phrase()); //doc.Add(new Phrase()); //doc.Add(new Phrase()); //doc.Add(firma); doc.NewPage(); } doc.Close(); _Archivo = ms.ToArray(); } } }
public LibroSobreTiempo(AufenPortalReportesDataContext db, EMPRESA empresa, vw_Ubicacione departamento, DateTime FechaDesde, DateTime FechaHasta, string path, string rut) { // Nombre del archivo y ubiación en el árbol de carpetas NombreArchivo = String.Format("{0}/{1}/SobreTiempos.pdf", empresa.Descripcion, departamento.Descripcion); // Vamos a buscar los datos que nos permitirtán armar elreporte IEnumerable<sp_LibroAsistenciaResult> resultadolibroSobretiempo = db.sp_LibroAsistencia( FechaDesde.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture), FechaHasta.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture), int.Parse(empresa.Codigo).ToString(), departamento.Codigo, rut).ToList(); IEnumerable<LibroAsistenciaDTO> libroSobretiempo = Mapper.Map<IEnumerable<sp_LibroAsistenciaResult>, IEnumerable<LibroAsistenciaDTO>>(resultadolibroSobretiempo); // Filtramos los casos que nos interesan libroSobretiempo = libroSobretiempo .Where(x => (x.Entrada.HasValue && x.EntradaTeorica.HasValue && x.Entrada < x.EntradaTeorica) || (x.Salida.HasValue && x.SalidaTeorica.HasValue && x.Salida > x.SalidaTeorica)); if (libroSobretiempo.Any()) { Configuracion(); Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 50, 35); using (var ms = new MemoryStream()) { PdfWriter pdfWriter = PdfWriter.GetInstance(doc, ms); pdfWriter.PageEvent = new Header(empresa, path); doc.Open(); foreach (var reporte in libroSobretiempo.Where(x => x.Rut != null) .GroupBy(x => new { x.Rut, x.IdDepartamento, x.IdEmpresa })) { var empleado = db.vw_Empleados.FirstOrDefault(x => x.IdEmpresa == empresa.Codigo && x.IdUbicacion == reporte.Key.IdDepartamento && x.Codigo == reporte.Key.Rut); if (empleado == null) { empleado = new vw_Empleado(); } doc.AddAuthor("Aufen"); doc.AddCreationDate(); doc.AddCreator("Aufen"); doc.AddTitle("Libro de Asistencia Personal - Sobretiempos"); // Agregamos el título y la bajada del reporte Paragraph parrafo = new Paragraph(); parrafo.Add(new Paragraph("Libro de Asistencia Personal", Titulo) { Alignment = Element.ALIGN_CENTER }); parrafo.Add(new Paragraph("Sobretiempos", Titulo) { Alignment = Element.ALIGN_CENTER }); doc.Add(parrafo); doc.Add(new Phrase()); PdfPTable tablaEncabezado = new PdfPTable(new float[] { 1, 5, 1, 5 }); tablaEncabezado.AddCell(new PdfPCell(new Phrase("Nombre:", Chico)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(empleado.NombreCompleto, Normal)) { Border = Rectangle.NO_BORDER, Colspan = 3 }); //tablaEncabezado.AddCell(new PdfPCell(new Phrase("Código:", Chico)) { Border = Rectangle.NO_BORDER }); //tablaEncabezado.AddCell(new PdfPCell(new Phrase(empleado.Codigo, Normal)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase("Empresa:", Chico)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase((empresa.Descripcion ?? String.Empty).Trim(), Normal)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase("Rut:", Chico)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(empleado.RutAufen, Normal)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase("Sucursal o Planta:", Chico)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(empleado.SucursalPlanta, Normal)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase("Cargo:", Chico)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(String.Empty, Normal)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase("Centro de Costo:", Chico)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(String.Empty, Normal)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(String.Empty, Normal)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(String.Empty, Normal)) { Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(new Phrase(String.Format("PERIODO: {0} a {1}", FechaDesde.ToShortDateString(), FechaHasta.ToShortDateString()), Normal)) { Colspan = 4, Border = Rectangle.NO_BORDER }); tablaEncabezado.AddCell(new PdfPCell(GetNomenclatura()) { Colspan = 4 }); doc.Add(tablaEncabezado); doc.Add(new Phrase()); // tabla PdfPTable tabla = new PdfPTable(new float[] { 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4 }); tabla.AddCell(new PdfPCell(new Phrase("Fecha", Chico)) { BorderWidthRight = 0.7f }); tabla.AddCell(new PdfPCell(new Phrase("HI", Chico))); tabla.AddCell(new PdfPCell(new Phrase("HS", Chico))); tabla.AddCell(new PdfPCell(new Phrase("HCol", Chico)) { BorderWidthRight = 0.7f}); tabla.AddCell(new PdfPCell(new Phrase("MI", Chico))); tabla.AddCell(new PdfPCell(new Phrase("MS", Chico)) { BorderWidthRight = 0.7f }); tabla.AddCell(new PdfPCell(new Phrase("HTH", Chico))); tabla.AddCell(new PdfPCell(new Phrase("HTN", Chico)) { BorderWidthRight = 0.7f }); tabla.AddCell(new PdfPCell(new Phrase("SIn", Chico))); tabla.AddCell(new PdfPCell(new Phrase("SSa", Chico))); tabla.AddCell(new PdfPCell(new Phrase("PT", Chico)) { BorderWidthRight = 0.7f }); tabla.AddCell(new PdfPCell(new Phrase("Cantidad", Chico))); tabla.AddCell(new PdfPCell(new Phrase("Motivo", Chico)) { BorderWidthRight = 0.7f }); // Filas con datos foreach (var sobretiempo in reporte) { //Fecha tabla.AddCell(new PdfPCell(new Phrase(sobretiempo.Fecha.Value.ToString("ddd dd/MM"), Chico)) { BorderWidthRight = 0.7f }); //Hora Ingreso tabla.AddCell(new PdfPCell(new Phrase(sobretiempo.EntradaTeorica.GetValueOrDefault(new DateTime()).ToString("HH:mm"), Chico))); //Hora Salida tabla.AddCell(new PdfPCell(new Phrase(sobretiempo.SalidaTeorica.GetValueOrDefault(new DateTime()).ToString("HH:mm"), Chico))); //Hora C0lación tabla.AddCell(new PdfPCell(new Phrase(new DateTime(sobretiempo.TiempoColacion.GetValueOrDefault(new TimeSpan()).Ticks).ToString("HH:mm"), Chico)) { BorderWidthRight = 0.7f }); //Marca Ingreso tabla.AddCell(new PdfPCell(new Phrase(sobretiempo.Entrada.GetValueOrDefault(new DateTime()).ToString("HH:mm"), Chico))); //Marca Salida tabla.AddCell(new PdfPCell(new Phrase(sobretiempo.Salida.GetValueOrDefault(new DateTime()).ToString("HH:mm"), Chico)) { BorderWidthRight = 0.7f }); //Hora pactada por horario tabla.AddCell(new PdfPCell(new Phrase(sobretiempo.printHorasPactadas, Chico))); //horas realizadas tabla.AddCell(new PdfPCell(new Phrase(sobretiempo.printHorasReales, Chico)) { BorderWidthRight = 0.7f }); //Sobrante Ingreso tabla.AddCell(new PdfPCell(new Phrase(sobretiempo.printSobreEntrada, Chico))); //Sobrante Salida tabla.AddCell(new PdfPCell(new Phrase(sobretiempo.printSobreSalida, Chico))); //P.Todo tabla.AddCell(new PdfPCell(new Phrase(sobretiempo.printSobreTiempo, Chico)) { BorderWidthRight = 0.7f }); //Cantidad tabla.AddCell(new PdfPCell(new Phrase("", Chico))); //Motivo tabla.AddCell(new PdfPCell(new Phrase(sobretiempo.Observacion, Chico)) { BorderWidthRight = 0.7f }); } tabla.AddCell(new PdfPCell(new Phrase(" ", Chico)) { Colspan = 1 , Border = Rectangle.NO_BORDER}); tabla.AddCell(new PdfPCell(new Phrase(" ", Chico)) { Colspan = 7, Border = Rectangle.TOP_BORDER, BorderWidthRight = 0.1f }); // Total SobreSalida tabla.AddCell(new PdfPCell(new Phrase(reporte.CalculaSobreEntrada(), Chico)) { Colspan = 1, BorderWidthRight = 0.1f }); // Total Sobre Entrada tabla.AddCell(new PdfPCell(new Phrase(reporte.CalculaSobreSalida(), Chico)) { Colspan = 1 }); // Total Horas Extra tabla.AddCell(new PdfPCell(new Phrase(reporte.CalculaSobreTiempo(), Chico)) { Colspan = 1, BorderWidthRight = 0.7f }); tabla.AddCell(new PdfPCell(new Phrase(" ", Normal)) { Colspan = 2, Border = Rectangle.TOP_BORDER, BorderWidthRight = 0.7f }); tabla.AddCell(new PdfPCell(new Phrase(" ", Normal)) { Colspan = 13, Border = Rectangle.NO_BORDER}); tabla.AddCell(new PdfPCell(GetFirma()) { Colspan = 13 }); doc.Add(tabla); doc.NewPage(); } doc.Close(); _Archivo = ms.ToArray(); } } }