Beispiel #1
0
        public void GenerateAdditionalexam(string filePDF, OrganizationDto MedicalCenter, PacientList DatosPaciente, UsuarioGrabo usuarioGraba, string MotivoComentario, List <Categoria> DataSource, List <AdditionalExamCustom> ListAdditional)
        {
            Document document = new Document(PageSize.A5, 20f, 20f, 20f, 20f);

            document.SetPageSize(iTextSharp.text.PageSize.A5);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include      = string.Empty;
            List <PdfPCell> cells        = null;
            float[]         columnWidths = null;
            PdfPTable       header2      = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            PdfPCell  cell            = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2_              = FontFactory.GetFont("Calibri", 6, Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.UNDERLINE, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontTitleTableAntecedentesOcupacionales  = FontFactory.GetFont("Arial", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueAntecedentesOcupacionales = FontFactory.GetFont("Arial", 5, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            #endregion


            #region CABECERA
            cells = new List <PdfPCell>();
            var pdfCell = new PdfPCell();

            if (MedicalCenter.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(MedicalCenter.b_Image));
                imagenEmpresa.ScalePercent(25);

                //imagenEmpresa.SetAbsolutePosition(40, 790);
                //document.Add(imagenEmpresa);
                pdfCell = new PdfPCell(imagenEmpresa)
                {
                    Colspan = 1, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColor = BaseColor.WHITE
                };
            }
            else
            {
                pdfCell = new PdfPCell(new Phrase("SIN LOGOTIPO", fontTitle2_))
                {
                    Colspan = 1, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, BorderColor = BaseColor.WHITE
                };
            }

            var names = new List <PdfPCell>()
            {
                pdfCell,
                new PdfPCell(new Phrase(MedicalCenter.v_Name, fontTitle2_))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(MedicalCenter.v_Address, fontTitle2_))
                {
                    Colspan = 2, HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColor = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 30f, 70f };
            table        = HandlingItextSharp.GenerateTableFromCells(names, columnWidths, null, fontTitleTable);
            document.Add(table);

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\nORDEN DE EXÁMENES MÉDICOS \nADICIONALES", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, BorderColor = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);

            string PacientFullName = "", Edad = "", FechaNac = "", TipoDoc = "", DocNumber = "", Direccion = "", Cargo = "", nHistoria = "---", Celular = "";

            if (DatosPaciente != null)
            {
                PacientFullName = DatosPaciente.v_FirstLastName + " " + DatosPaciente.v_SecondLastName + " " + DatosPaciente.v_FirstName;
                Edad            = DatosPaciente.Edad.ToString();
                FechaNac        = DatosPaciente.d_Birthdate.Value.ToShortDateString();
                DocNumber       = DatosPaciente.v_DocNumber == null ? "---" : DatosPaciente.v_DocNumber;
                Direccion       = string.IsNullOrEmpty(DatosPaciente.v_AdressLocation) ? "---" : DatosPaciente.v_AdressLocation;
                Cargo           = string.IsNullOrEmpty(DatosPaciente.v_CurrentOccupation) ? "---" : DatosPaciente.v_CurrentOccupation;
                Celular         = string.IsNullOrEmpty(DatosPaciente.v_TelephoneNumber) ? "---" : DatosPaciente.v_TelephoneNumber;
                if (DatosPaciente.i_DocTypeId == 1)
                {
                    TipoDoc = "DNI";
                }
                else if (DatosPaciente.i_DocTypeId == 2)
                {
                    TipoDoc = "Pasaporte";
                }
                else if (DatosPaciente.i_DocTypeId == 3)
                {
                    TipoDoc = "Licencia de Conducir";
                }
                else if (DatosPaciente.i_DocTypeId == 4)
                {
                    TipoDoc = "Carnet de Extranjeria";
                }
            }

            //Datos del paciente
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("NOMBRES:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(PacientFullName, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("EDAD:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(Edad, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("F. NAC:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(FechaNac, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase(TipoDoc + ":", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(DocNumber, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("DIRECCIÓN:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(Direccion, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("CARGO:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(Cargo, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("N° HISTORIA:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("CSL-" + DocNumber, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("CELULAR:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(Celular, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 12f, 27f, 15f, 23f, 12f, 11f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);


            #endregion

            #region CUERPO
            //resumen

            var pdfCellComentario = new PdfPCell();
            if (MotivoComentario.Length > 0)
            {
                pdfCellComentario = new PdfPCell(new Phrase(MotivoComentario, fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT,
                    VerticalAlignment   = iTextSharp.text.Element.ALIGN_MIDDLE,
                    MinimumHeight       = 30f,
                    BorderColor         = BaseColor.WHITE
                };
            }
            else
            {
                pdfCellComentario = new PdfPCell(new Phrase("........................................................................................................................................................................ \n........................................................................................................................................................................", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, BorderColor = BaseColor.WHITE
                };
            }
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("RESUMEN", fontTitleTableNegro))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                pdfCellComentario,
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);


            //exámenes
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("EXÁMENES", fontTitleTableNegro))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);

            foreach (var category in DataSource)
            {
                //exámenes
                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("* ", fontTitleTable))
                    {
                        HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                    },
                    new PdfPCell(new Phrase(category.v_CategoryName, fontTitleTable))
                    {
                        HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                    },
                };
                columnWidths = new float[] { 10f, 90f };
                table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
                document.Add(table);

                foreach (var component in category.Componentes)
                {
                    string estado = "";
                    var    obj    = ListAdditional.Find(x => x.ComponentId == component.v_ComponentId);
                    if (obj != null)
                    {
                        if (obj.IsProcessed == 1)
                        {
                            estado = " ( AGENDADO)";
                        }
                        else
                        {
                            estado = " ( POR AGENDAR )";
                        }
                    }

                    cells = new List <PdfPCell>()
                    {
                        new PdfPCell(new Phrase("- ", fontColumnValue))
                        {
                            HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                        },
                        new PdfPCell(new Phrase(component.v_ComponentName + estado, fontColumnValue))
                        {
                            HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                        },
                    };
                    columnWidths = new float[] { 15f, 85f };
                    table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
                    document.Add(table);
                }
            }



            //datos medicos
            var    cellFirma = new PdfPCell();
            string NombreMedico = "---", CMP = "---";
            if (usuarioGraba != null)
            {
                NombreMedico = usuarioGraba.Nombre == null ? "---" : usuarioGraba.Nombre;
                CMP          = usuarioGraba == null ? "---" : usuarioGraba.CMP;

                if (usuarioGraba.Firma != null)
                {
                    cellFirma = new PdfPCell(HandlingItextSharp.GetImage(usuarioGraba.Firma, null, null, 110, 40))
                    {
                        Colspan = 1, Rowspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColor = BaseColor.BLACK
                    };
                }
            }
            else
            {
                cellFirma = new PdfPCell(new Phrase("FIRMA", fontTitle2_))
                {
                    Colspan = 1, Rowspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.BLACK
                };
            }


            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("DATOS MÉDICOS", fontTitle2))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.BLACK
                },
                cellFirma,
                new PdfPCell(new Phrase("NOMBRE:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.BLACK
                },
                new PdfPCell(new Phrase(NombreMedico, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("CMP:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.BLACK
                },
                new PdfPCell(new Phrase(CMP, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.BLACK
                },
            };
            columnWidths = new float[] { 15f, 35f, 50f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion


            document.Close();
            writer.Close();
            writer.Dispose();
        }
Beispiel #2
0
        public Paragraph GetPageEight(Response <QuotationDto> response, string fullNameUser)
        {
            var   data     = response.Data;
            Chunk chunkOne = new Chunk("PROPUESTA ECONÓMICA\n", textUtils.fontBold12Black);

            Phrase phrase = new Phrase();

            phrase.Add(chunkOne);

            Paragraph elements = new Paragraph();

            elements.Add(phrase);
            elements.Alignment = Element.ALIGN_LEFT;


            var examenes = new List <Detail>();
            var perfiles = data.QuotationProfile;

            foreach (var perfil in perfiles)
            {
                foreach (var item in perfil.ProfileComponent)
                {
                    var oDetail = new Detail();
                    oDetail.ComponentId      = item.ComponentId;
                    oDetail.ComponentName    = item.ComponentName;
                    oDetail.Price            = item.SalePrice.Value;
                    oDetail.AgeConditionalId = item.AgeConditionalId;
                    oDetail.Age = item.Age;
                    oDetail.GenderConditionalId = item.GenderConditionalId;
                    examenes.Add(oDetail);
                }
            }

            examenes = examenes.GroupBy(p => p.ComponentName).Select(p => p.First()).ToList();

            var cells = new List <PdfPCell>();

            //ROW 1
            cells.Add(new PdfPCell(new Phrase("FECHA: " + DateTime.Now.ToString("MM/dd/yyyy"), textUtils.font08Black))
            {
                Colspan = 2, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE
            });
            cells.Add(new PdfPCell(new Phrase("Tipo de Examen Ocupacional", textUtils.font08Black))
            {
                Colspan = data.QuotationProfile.Count, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
            });

            //ROW 2
            var typeExams = data.QuotationProfile.GroupBy(g => g.ServiceTypeName).Select(s => new { name = s.Key, count = s.Count() }).ToList();

            cells.Add(new PdfPCell(new Phrase("Ejecutiva: " + fullNameUser, textUtils.font08Black))
            {
                Colspan = 2
            });
            foreach (var typeExam in typeExams)
            {
                var colspanValue = typeExam.count;
                cells.Add(new PdfPCell(new Phrase(typeExam.name, textUtils.font08Black))
                {
                    Colspan = colspanValue, HorizontalAlignment = Element.ALIGN_CENTER
                });
            }

            //ROW 3
            cells.Add(new PdfPCell(new Phrase("Grupos de Vigilancia Médica Similar (GVMS)", textUtils.font08Black))
            {
                Colspan = 2
            });
            foreach (var profile in data.QuotationProfile)
            {
                cells.Add(new PdfPCell(new Phrase(profile.ProfileName, textUtils.font08Black))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER, BackgroundColor = BaseColor.GRAY
                });
            }

            //ROW 4
            cells.Add(new PdfPCell(new Phrase("Exámenes Ocupacionales", textUtils.font08Black)));
            cells.Add(new PdfPCell(new Phrase("P.U.", textUtils.font08Black))
            {
                HorizontalAlignment = Element.ALIGN_CENTER
            });
            foreach (var profile in data.QuotationProfile)
            {
                cells.Add(new PdfPCell(new Phrase(profile.ProfileComponent.Count.ToString(), textUtils.font08Black))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }

            //ROW 5
            foreach (var item in examenes)
            {
                cells.Add(new PdfPCell(new Phrase(item.ComponentName, textUtils.font08Black)));
                cells.Add(new PdfPCell(new Phrase("S/." + item.Price.ToString(), textUtils.font08Black)));
                foreach (var profile in data.QuotationProfile)
                {
                    var existe = profile.ProfileComponent.Find(p => p.ComponentId == item.ComponentId);
                    if (existe != null)
                    {
                        cells.Add(new PdfPCell(new Phrase("X", textUtils.font08Black))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER
                        });
                    }
                    else
                    {
                        cells.Add(new PdfPCell(new Phrase("", textUtils.font08Black)));
                    }
                }
            }

            //ROW 6
            cells.Add(new PdfPCell(new Phrase("Sub total por GVMS", textUtils.font08Black))
            {
                Colspan = 2
            });
            foreach (var profile in data.QuotationProfile)
            {
                cells.Add(new PdfPCell(new Phrase("S/." + profile.ProfileComponent.Sum(p => p.SalePrice).ToString(), textUtils.font08Black))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }

            //ROW 7
            cells.Add(new PdfPCell(new Phrase("Total (No incluye IGV)", textUtils.font08Black))
            {
                Colspan = 2
            });
            decimal?total = 0;

            foreach (var profile in data.QuotationProfile)
            {
                total += profile.ProfileComponent.Sum(p => p.SalePrice);
            }

            cells.Add(new PdfPCell(new Phrase("S/." + total.ToString(), textUtils.font08Black))
            {
                Colspan = data.QuotationProfile.Count, HorizontalAlignment = Element.ALIGN_CENTER
            });


            var table = HandlingItextSharp.GenerateTableFromCells(cells, HandlingItextSharp.GetColumns(2 + data.QuotationProfile.Count), "PROTOCOLO EXÁMENES MÉDICOS OCUPACIONALES N°: " + data.Code, textUtils.font12Black, new BaseColor(252, 252, 252));

            elements.Add(table);


            //TABLA EXAMENES ADICIONALES
            var cellsAdi    = new List <PdfPCell>();
            var adicionales = data.AdditionalComponentsQuote;

            foreach (var item in adicionales)
            {
                cellsAdi.Add(new PdfPCell(new Phrase(item.ComponentName, textUtils.font08Black)));
                cellsAdi.Add(new PdfPCell(new Phrase("S/." + item.SalePrice.ToString(), textUtils.font08Black)));
                cellsAdi.Add(new PdfPCell(new Phrase("", textUtils.font08Black))
                {
                    Colspan = typeExams.Count + 3
                });
            }

            var tableAddic = HandlingItextSharp.GenerateTableFromCells(cellsAdi, HandlingItextSharp.GetColumns(2 + data.QuotationProfile.Count), "EXÁMENES ADICIONALES", textUtils.font12Black, new BaseColor(252, 252, 252));

            elements.Add(tableAddic);

            //TABLA CONDICIONALES
            var cellsCond = new List <PdfPCell>();

            foreach (var exam in examenes)
            {
                if (exam.GenderConditionalId != -1)
                {
                    cellsCond.Add(new PdfPCell(new Phrase(exam.ComponentName, textUtils.font08Black)));
                }

                if (exam.AgeConditionalId != -1)
                {
                    cellsCond.Add(new PdfPCell(new Phrase(exam.ComponentName, textUtils.font08Black)));
                }
            }

            var tableCondi = HandlingItextSharp.GenerateTableFromCells(cellsCond, new float[] { 100f }, "CONDICIONALES", textUtils.font12Black, new BaseColor(252, 252, 252));

            elements.Add(tableCondi);



            return(elements);
        }
Beispiel #3
0
        public static void CrearOrdenServicio(bool MostrarPrecio, List <ServiceOrderPdf> ListaServiceOrder, OrganizationCustom infoEmpresaPropietaria, string EmpresaCliente, string Fecha, string Usuario, string filePDF)
        {
            Document document = new Document();

            document.SetPageSize(iTextSharp.text.PageSize.A4);

            //try
            //{NO_BORDER
            // step 2: we create aPA writer that listens to the document
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));

            //create an instance of your PDFpage class. This is the class we generated above.
            pdfPage page = new pdfPage();

            //set the PageEvent of the pdfWriter instance to the instance of our PDFPage class
            writer.PageEvent = page;

            // step 3: we open the document
            document.Open();
            // step 4: we Add content to the document
            // we define some fonts
            #region Declaration Tables

            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.White);
            string          include      = string.Empty;
            List <PdfPCell> cells        = null;
            float[]         columnWidths = null;
            //string[] columnValues = null;
            string[] columnHeaders = null;


            PdfPTable filiationWorker = new PdfPTable(8);

            PdfPTable table = null;

            PdfPCell cell = null;

            #endregion

            #region Fonts

            Font fontTitle1               = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue        = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueNegrita = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontAptitud = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            #region Logo Empresa Propietaria

            PdfPCell CellLogo = null;
            cells = new List <PdfPCell>();
            if (infoEmpresaPropietaria.b_Image != null)
            {
                CellLogo = new PdfPCell(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image, 30F))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                };
            }
            else
            {
                CellLogo = new PdfPCell(new Phrase("sin logo ", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                };
            }

            cells.Add(CellLogo);
            columnWidths = new float[] { 100f };

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);
            document.Add(table);

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase(EmpresaCliente, fontSubTitleNegroNegrita))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase(infoEmpresaPropietaria.v_Sede + ", " + Fecha, fontSubTitleNegroNegrita))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_RIGHT
                },
            };

            columnWidths = new float[] { 100f };

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);
            document.Add(table);

            #endregion

            #region Texto en duro
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase(" ", fontColumnValue)),
                new PdfPCell(new Phrase("Atte.", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("Es muy grato dirigirme a usted, saludarlos y contestar sus requerimientos. Además, ofrecerle en condiciones especiales los servicios de nuestra empresa y así iniciar el programa de salud ocupacional que brindamos.", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                //new PdfPCell(new Phrase("nuestra empresa y así iniciar el programa de salud ocupacional que brindamos.", fontColumnValue)){HorizontalAlignment = PdfPCell.ALIGN_LEFT},
                new PdfPCell(new Phrase("Prevenciones Ocupacionales de Salud SAC, es una empresa constituida por un staff de profesionales de salud altamente calificados, nuestra primordial misión es brindarles LA EVALUACIÓN MÉDICA OCUPACIONAL de acuerdo a ley 29783 de SEGURIDAD Y SALUD EN EL TRABAJO, dentro de la infraestructura de cada empresa a nivel nacional.", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                //new PdfPCell(new Phrase("primordial misión es brindarles LA EVALUACIÓN MÉDICA OCUPACIONAL de acuerdo a ley 29783 de SEGURIDAD Y SALUD EN", fontColumnValue)){HorizontalAlignment = PdfPCell.ALIGN_LEFT},
                //new PdfPCell(new Phrase("EL TRABAJO, dentro de la infraestructura de cada empresa a nivel nacional.", fontColumnValue)){HorizontalAlignment = PdfPCell.ALIGN_LEFT},
                new PdfPCell(new Phrase("Así mismo nuestras Evaluaciones Médicas Ocupacionales serán detalladas a continuación según sus referencias y a solicitud:", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase(" ", fontColumnValue)),
                new PdfPCell(new Phrase(" ", fontColumnValue)),
            };
            columnWidths = new float[] { 100f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);

            document.Add(filiationWorker);
            #endregion

            #region Parte Dinámica
            cells = new List <PdfPCell>();


            foreach (var Cabecera in ListaServiceOrder)
            {
                cell = new PdfPCell(new Phrase(Cabecera.EmpresaCliente, fontColumnValueNegrita))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                };
                cells.Add(cell);

                var ListaFiltrada = Cabecera.DetalleServiceOrder.FindAll(p => p.v_Precio != 0.00);
                foreach (var Detalle in ListaFiltrada)
                {
                    cell = new PdfPCell(new Phrase(Detalle.Componente, fontColumnValueNegrita))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_RIGHT
                    };
                    cells.Add(cell);
                    string Valor = MostrarPrecio == true?Detalle.v_Precio.ToString() == "0.01" ? "COSTO CERO" : Detalle.v_Precio.ToString() : Detalle.v_Precio.ToString() == "0.01" ? "COSTO CERO" : "";

                    if (Valor != "")
                    {
                        Valor = "S/." + Valor;
                    }

                    cell = new PdfPCell(new Phrase(Valor, fontColumnValueNegrita))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_CENTER
                    };
                    cells.Add(cell);
                }
                cell = new PdfPCell(new Phrase(" ", fontColumnValueNegrita))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_CENTER, Border = PdfPCell.NO_BORDER
                };
                cells.Add(cell);

                cell = new PdfPCell(new Phrase("TOTAL: S/. ", fontColumnValueNegrita))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_RIGHT, Border = PdfPCell.NO_BORDER
                };
                cells.Add(cell);


                cell = new PdfPCell(new Phrase(Cabecera.TotalProtocolo.ToString(), fontColumnValueNegrita))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                };
                cells.Add(cell);

                cell = new PdfPCell(new Phrase("Los precios no incluyen I.G.V.", fontColumnValueNegrita))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_CENTER, Border = PdfPCell.NO_BORDER
                };
                cells.Add(cell);

                cell = new PdfPCell(new Phrase(" ", fontColumnValueNegrita))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_CENTER, Border = PdfPCell.NO_BORDER
                };
                cells.Add(cell);
            }


            columnWidths = new float[] { 50f, 50f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

            document.Add(filiationWorker);

            #endregion

            #region Texto en duro

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase(" ", fontColumnValue)),
                new PdfPCell(new Phrase("Además, Prevenciones Ocupacionales de Salud se compromete realizar a COSTOCERO parte delas evaluaciones del protocolo exigidas según la 'Ley de seguridad y salud en el trabajo 29783' y el Documento Técnico según 'Resolución Ministerial 312' para la totalidad de sus colaboradores, bajo la modalidad SEMIPAGADA.", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                //new PdfPCell(new Phrase("según la 'Ley de seguridad y salud en el trabajo 29783' y el Documento Técnico según 'Resolución Ministerial 312' para la totalidad de", fontColumnValue)){HorizontalAlignment = PdfPCell.ALIGN_LEFT},
                //new PdfPCell(new Phrase("sus colaboradores, bajo la modalidad SEMIPAGADA.", fontColumnValue)){HorizontalAlignment = PdfPCell.ALIGN_LEFT},
                //new PdfPCell(new Phrase(" ", fontColumnValue)),
                new PdfPCell(new Phrase("PARA QUE TAL MODALIDAD SE HAGA EFECTIVA, queremos hacer mención que si durante las evaluaciones sus trabajadores equieran o deseen algún servicio brindado por nuestra institución en el área de Optometría y Laboratorio se les otorgará un crédito inmediato en cuotas (2 a 3 meses dependiendo del monto), al cual podrán acceder en forma voluntaria, bajo la modalidad: Descuento por planilla.", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                //new PdfPCell(new Phrase("requieran o deseen algún servicio brindado por nuestra institución en el área de Optometría y Laboratorio se les otorgará un crédito", fontColumnValue)){HorizontalAlignment = PdfPCell.ALIGN_LEFT},
                //new PdfPCell(new Phrase("inmediato en cuotas (2 a 3 meses dependiendo del monto), al cual podrán acceder en forma voluntaria, bajo la modalidad: Descuento por", fontColumnValue)){HorizontalAlignment = PdfPCell.ALIGN_LEFT},
                //new PdfPCell(new Phrase("planilla.", fontColumnValue)){HorizontalAlignment = PdfPCell.ALIGN_LEFT},
                new PdfPCell(new Phrase("Esperamos poder atender a su empresa recordándole que esta opción de brindar un servicio de salud de alta calidad está disponible vuestra empresa; nos despedimos quedando a sus gratas órdenes.", fontColumnValue)),
                //new PdfPCell(new Phrase("vuestra empresa; nos despedimos quedando a sus gratas órdenes.", fontColumnValue)),
                //new PdfPCell(new Phrase(" ", fontColumnValue)),
                //new PdfPCell(new Phrase("Esperamos poder atender a su empresa recordándole que esta opción de brindar un servicio de salud de alta calidad está disponible para", fontColumnValue)),
                //new PdfPCell(new Phrase("vuestra empresa; nos despedimos quedando a sus gratas órdenes.", fontColumnValue)),
                new PdfPCell(new Phrase(" ", fontColumnValue)),
                new PdfPCell(new Phrase("Atentamente. ", fontColumnValue)),

                new PdfPCell(new Phrase(" ", fontColumnValue)),
                new PdfPCell(new Phrase(Usuario, fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT, Border = PdfPCell.NO_BORDER
                },
                new PdfPCell(new Phrase("Coordinadora Médico Ocupacional", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT, Border = PdfPCell.NO_BORDER
                },
                new PdfPCell(new Phrase(infoEmpresaPropietaria.v_Name, fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT, Border = PdfPCell.NO_BORDER
                },
            };
            columnWidths = new float[] { 100f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);

            document.Add(filiationWorker);

            #endregion

            document.Close();
            writer.Close();
            writer.Dispose();
            //RunFile(filePDF);
        }
        public static bool GenerateCotizacion(List <ServiceOrderDetailCustom> ListServiceOrder, OrganizationDto infoEmpresaPropietaria, ServiceOrderCustom dataServiceOrder, string filePDF)
        {
            Document document = new Document(PageSize.A4, 30f, 30f, 45f, 41f);

            document.SetPageSize(PageSize.A4);
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));

            try
            {
                pdfPage page = new pdfPage();
                writer.PageEvent = page;
                document.Open();

                #region Declaration Tables
                var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
                string          include       = string.Empty;
                List <PdfPCell> cells         = null;
                List <PdfPCell> cells2        = null;
                float[]         columnWidths  = null;
                string[]        columnValues  = null;
                string[]        columnHeaders = null;
                PdfPTable       header2       = new PdfPTable(6);
                header2.HorizontalAlignment = Element.ALIGN_CENTER;
                header2.WidthPercentage     = 100;
                float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
                header2.SetWidths(widths1);
                PdfPTable companyData = new PdfPTable(6);
                companyData.HorizontalAlignment = Element.ALIGN_CENTER;
                companyData.WidthPercentage     = 100;
                float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
                companyData.SetWidths(widthscolumnsCompanyData);
                PdfPTable filiationWorker = new PdfPTable(4);
                PdfPTable table           = null;
                PdfPCell  cell            = null;
                PdfPCell  cell2           = null;
                document.Add(new Paragraph("\r\n"));
                float HeightTitle  = 40f;
                float SingleHeight = 25f;
                #endregion

                #region Fonts
                Font fontTitle1               = FontFactory.GetFont("Calibri", 10, Font.BOLD, new BaseColor(System.Drawing.Color.Black));
                Font fontTitle1_1             = FontFactory.GetFont("Calibri", 8, Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
                Font fontTitle2               = FontFactory.GetFont("Calibri", 7, Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
                Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, Font.BOLD, new BaseColor(System.Drawing.Color.Black));
                Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, Font.BOLD, new BaseColor(System.Drawing.Color.Black));
                Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, Font.BOLD, new BaseColor(System.Drawing.Color.White));
                Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, Font.BOLD, new BaseColor(System.Drawing.Color.Black));

                Font fontColumnValue      = FontFactory.GetFont("Calibri", 7, Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
                Font fontColumnValueBold  = FontFactory.GetFont("Calibri", 7, Font.BOLD, new BaseColor(System.Drawing.Color.Black));
                Font fontColumnValueBold1 = FontFactory.GetFont("Calibri", 7, Font.BOLD, new BaseColor(System.Drawing.Color.White));

                Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, Font.BOLD, new BaseColor(System.Drawing.Color.Black));
                #endregion



                PdfPCell cellLogo = new PdfPCell(new Phrase("SIN LOGO", fontTitle1))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = HeightTitle
                };
                if (infoEmpresaPropietaria != null)
                {
                    if (infoEmpresaPropietaria.b_Image != null)
                    {
                        Image imagenEmpresa = Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image));
                        imagenEmpresa.ScalePercent(25);
                        cellLogo = new PdfPCell(imagenEmpresa)
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = HeightTitle
                        };
                    }
                }
                var cellsTit = new List <PdfPCell>()
                {
                    cellLogo,
                    new PdfPCell(new Phrase("PROPUESTA ECONÓMICA DE \nEXAMEN MEDICO OCUPACIONAL (EMO)", fontTitle1))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = HeightTitle
                    },
                    new PdfPCell(new Phrase("", fontTitle1))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = HeightTitle
                    },
                };
                columnWidths = new float[] { 33f, 34f, 33f };
                table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, Rectangle.NO_BORDER, null, fontTitleTable);
                document.Add(table);

                #region CABECERA
                cellsTit = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("Empresa Cliente :", fontColumnValueBold))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase(dataServiceOrder.v_OrganizationName, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase("Fecha Emisión :", fontColumnValueBold))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase(dataServiceOrder.d_InsertDate.ToString(), fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },

                    new PdfPCell(new Phrase("Dirección :", fontColumnValueBold))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase(dataServiceOrder.v_OrganizationAdress, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },

                    new PdfPCell(new Phrase("RUC :", fontColumnValueBold))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase(dataServiceOrder.v_IdentificationNumber, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },

                    new PdfPCell(new Phrase("Representante :", fontColumnValueBold))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase(dataServiceOrder.v_ContacName, fontColumnValue))
                    {
                        Colspan = 3, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },

                    new PdfPCell(new Phrase("Para la propuesta económica del EMO, se ha tomado en cuenta la Normativa Legal Nacional vigente establecida mediante la  Ley de Seguridad y Salud en el Trabajo Nº 29783, la Resolución Ministerial RM 312 - 2011 - MINSA , con sus respectivas  modificatorias y las exigencias mismas de la Empresa solicitante.", fontColumnValue))
                    {
                        Colspan = 4, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },

                    new PdfPCell(new Phrase(infoEmpresaPropietaria.v_Name + ",Empresa especializada en Servicios  Medico Ocupacionales, cuenta con las licencias, autorizaciones  legales y la acreditación por DIGESA para la realización de los EMO. El Staff de Profesionales de Salud, cuenta con  Diplomados, Maestría en Salud Ocupacional, así como Certificaciones Internacionales (OIT, ALAT, CAOH) para la lectura e  interpretación de espirometría, audiometría y placas radiográficas.", fontColumnValue))
                    {
                        Colspan = 4, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                };

                columnWidths = new float[] { 20f, 45f, 15f, 20f };
                table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, Rectangle.NO_BORDER, null, fontTitleTable);
                document.Add(table);
                #endregion



                #region DETALLES


                foreach (var detail in ListServiceOrder)
                {
                    cellsTit = new List <PdfPCell>()
                    {
                        new PdfPCell(new Phrase("Protocolo de atenciòn o Perfil:" + detail.v_GesoName + "-" + detail.v_ProtocolTypeName, fontColumnValue))
                        {
                            Colspan = 4, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                        },

                        new PdfPCell(new Phrase("", fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                        },
                        new PdfPCell(new Phrase("Exámenes Ocupacionales", fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                        },
                        new PdfPCell(new Phrase("Precio", fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                        },
                        new PdfPCell(new Phrase("", fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                        },
                    };

                    columnWidths = new float[] { 20f, 40f, 20f, 20f };
                    table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, Rectangle.NO_BORDER, null, fontTitleTable);
                    document.Add(table);

                    float totalPrice = 0;
                    foreach (var comp in detail.ProtocolComponents)
                    {
                        totalPrice += comp.r_Price;
                        cellsTit    = new List <PdfPCell>()
                        {
                            new PdfPCell(new Phrase("", fontColumnValue))
                            {
                                HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                            },
                            new PdfPCell(new Phrase(comp.v_Name, fontColumnValue))
                            {
                                HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                            },
                            new PdfPCell(new Phrase(comp.r_Price.ToString("N2"), fontColumnValue))
                            {
                                HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                            },
                            new PdfPCell(new Phrase("", fontColumnValue))
                            {
                                HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                            },
                        };

                        columnWidths = new float[] { 20f, 40f, 20f, 20f };
                        table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, Rectangle.NO_BORDER, null, fontTitleTable);
                        document.Add(table);
                    }
                    cellsTit = new List <PdfPCell>()
                    {
                        new PdfPCell(new Phrase("", fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                        },
                        new PdfPCell(new Phrase("Total ", fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                        },
                        new PdfPCell(new Phrase(totalPrice.ToString("N2"), fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                        },
                        new PdfPCell(new Phrase("", fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                        },
                    };

                    columnWidths = new float[] { 20f, 40f, 20f, 20f };
                    table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, Rectangle.NO_BORDER, null, fontTitleTable);
                    document.Add(table);
                }
                PdfPCell cellFirma = new PdfPCell(new Phrase("SIN FIRMA", fontTitle1))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = HeightTitle
                };
                if (dataServiceOrder != null)
                {
                    if (dataServiceOrder.b_SignatureImage != null)
                    {
                        Image firmaMedico = Image.GetInstance(HandlingItextSharp.GetImage(dataServiceOrder.b_SignatureImage));
                        firmaMedico.ScalePercent(20);
                        cellFirma = new PdfPCell(firmaMedico)
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = HeightTitle
                        };
                    }
                }
                cellsTit = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                    cellFirma,
                    new PdfPCell(new Phrase("", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_BOTTOM, MinimumHeight = SingleHeight
                    },

                    new PdfPCell(new Phrase("", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_BOTTOM, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase("_____________________________________________________", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_BOTTOM, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase("", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_BOTTOM, MinimumHeight = SingleHeight
                    },

                    new PdfPCell(new Phrase("", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_BOTTOM, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase("Firma y Sello", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase("", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_BOTTOM, MinimumHeight = SingleHeight
                    },
                };

                columnWidths = new float[] { 50f, 30f, 20f };
                table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, Rectangle.NO_BORDER, null, fontTitleTable);
                document.Add(table);
                #endregion
                document.Close();
                writer.Close();
                writer.Dispose();
                return(true);
            }
            catch (Exception ex)
            {
                document.Close();
                writer.Close();
                writer.Dispose();
                return(false);
            }
        }
        public static bool GenerateOrderService(List <ServiceOrderDetailCustom> ListServiceOrder, OrganizationDto infoEmpresaPropietaria, ServiceOrderCustom dataServiceOrder, string filePDF)
        {
            Document document = new Document(PageSize.A4, 30f, 30f, 45f, 41f);

            document.SetPageSize(PageSize.A4);
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));

            try
            {
                pdfPage page = new pdfPage();
                writer.PageEvent = page;
                document.Open();

                #region Declaration Tables
                var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
                string          include       = string.Empty;
                List <PdfPCell> cells         = null;
                List <PdfPCell> cells2        = null;
                float[]         columnWidths  = null;
                string[]        columnValues  = null;
                string[]        columnHeaders = null;
                PdfPTable       header2       = new PdfPTable(6);
                header2.HorizontalAlignment = Element.ALIGN_CENTER;
                header2.WidthPercentage     = 100;
                float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
                header2.SetWidths(widths1);
                PdfPTable companyData = new PdfPTable(6);
                companyData.HorizontalAlignment = Element.ALIGN_CENTER;
                companyData.WidthPercentage     = 100;
                float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
                companyData.SetWidths(widthscolumnsCompanyData);
                PdfPTable filiationWorker = new PdfPTable(4);
                PdfPTable table           = null;
                PdfPCell  cell            = null;
                PdfPCell  cell2           = null;
                document.Add(new Paragraph("\r\n"));
                float HeightTitle  = 40f;
                float SingleHeight = 25f;
                #endregion

                #region Fonts
                Font fontTitle1               = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
                Font fontTitle1_1             = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
                Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
                Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
                Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
                Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
                Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

                Font fontColumnValue      = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
                Font fontColumnValueBold  = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
                Font fontColumnValueBold1 = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));

                Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
                #endregion



                PdfPCell cellLogo = new PdfPCell(new Phrase("SIN LOGO", fontTitle1))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = HeightTitle
                };
                if (infoEmpresaPropietaria != null)
                {
                    if (infoEmpresaPropietaria.b_Image != null)
                    {
                        Image imagenEmpresa = Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image));
                        imagenEmpresa.ScalePercent(25);
                        cellLogo = new PdfPCell(imagenEmpresa)
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = HeightTitle
                        };
                    }
                }
                var cellsTit = new List <PdfPCell>()
                {
                    cellLogo,
                    new PdfPCell(new Phrase("ORDEN DE SERVICIO \n" + dataServiceOrder.v_CustomServiceOrderId, fontTitle1))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = HeightTitle
                    },
                    new PdfPCell(new Phrase("", fontTitle1))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = HeightTitle
                    },
                };
                columnWidths = new float[] { 33f, 34f, 33f };
                table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, Rectangle.NO_BORDER, null, fontTitleTable);
                document.Add(table);

                #region CABECERA
                cellsTit = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("Empresa Cliente :", fontColumnValueBold))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase(dataServiceOrder.v_OrganizationName, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase("Fecha Emisión :", fontColumnValueBold))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase(dataServiceOrder.d_InsertDate.ToString(), fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },

                    new PdfPCell(new Phrase("Dirección :", fontColumnValueBold))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase(dataServiceOrder.v_OrganizationAdress, fontColumnValue))
                    {
                        Colspan = 3, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },

                    new PdfPCell(new Phrase("Representante :", fontColumnValueBold))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase(dataServiceOrder.v_ContacName, fontColumnValue))
                    {
                        Colspan = 3, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },

                    new PdfPCell(new Phrase("MEDIANTE LA PRESENTE SOLICITO EL SERVICIO DE EXAMENES MEDICOS OCUPACIONALES AL PERSONAL DE MI REPRESENTADA, EN SU CLINICA ESPECIALIZADA EN SALUD OCUPACIONAL.", fontColumnValue))
                    {
                        Colspan = 4, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                };

                columnWidths = new float[] { 20f, 45f, 15f, 20f };
                table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, Rectangle.NO_BORDER, null, fontTitleTable);
                document.Add(table);
                #endregion



                #region DETALLES


                foreach (var detail in ListServiceOrder)
                {
                    cellsTit = new List <PdfPCell>()
                    {
                        new PdfPCell(new Phrase("PARA UN NÚMERO DE " + detail.i_NumberOfWorkerProtocol + " TRABAJADORES CON UN COSTO APROXIMADO DE S/" + detail.r_Total + " NUEVOS SOLES, DEPENDIENDO DE LA FACTURACIÓN FINAL DEL NÚMERO DE ATENCIONES REALIZADAS EN LA CLÍNICA.", fontColumnValue))
                        {
                            Colspan = 4, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                        },

                        new PdfPCell(new Phrase("", fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                        },
                        new PdfPCell(new Phrase("Exámenes Ocupacionales(" + detail.v_ProtocolTypeName + ")", fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                        },
                        new PdfPCell(new Phrase("Precio", fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                        },
                        new PdfPCell(new Phrase("", fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                        },
                    };

                    columnWidths = new float[] { 20f, 40f, 20f, 20f };
                    table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, Rectangle.NO_BORDER, null, fontTitleTable);
                    document.Add(table);

                    float totalPrice = 0;
                    foreach (var comp in detail.ProtocolComponents)
                    {
                        totalPrice += comp.r_Price;
                        cellsTit    = new List <PdfPCell>()
                        {
                            new PdfPCell(new Phrase("", fontColumnValue))
                            {
                                HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                            },
                            new PdfPCell(new Phrase(comp.v_Name, fontColumnValue))
                            {
                                HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                            },
                            new PdfPCell(new Phrase(comp.r_Price.ToString("N2"), fontColumnValue))
                            {
                                HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                            },
                            new PdfPCell(new Phrase("", fontColumnValue))
                            {
                                HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                            },
                        };

                        columnWidths = new float[] { 20f, 40f, 20f, 20f };
                        table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, Rectangle.NO_BORDER, null, fontTitleTable);
                        document.Add(table);
                    }
                    cellsTit = new List <PdfPCell>()
                    {
                        new PdfPCell(new Phrase("", fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                        },
                        new PdfPCell(new Phrase("Total ", fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                        },
                        new PdfPCell(new Phrase(totalPrice.ToString("N2"), fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                        },
                        new PdfPCell(new Phrase("", fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                        },
                    };

                    columnWidths = new float[] { 20f, 40f, 20f, 20f };
                    table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, Rectangle.NO_BORDER, null, fontTitleTable);
                    document.Add(table);
                }

                cellsTit = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase("APROBADO: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase("_____________________________________________________", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_BOTTOM, MinimumHeight = SingleHeight
                    },
                    new PdfPCell(new Phrase("", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, MinimumHeight = SingleHeight
                    },
                };

                columnWidths = new float[] { 20f, 10f, 40f, 30f };
                table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, Rectangle.NO_BORDER, null, fontTitleTable);
                document.Add(table);
                #endregion
                document.Close();
                writer.Close();
                writer.Dispose();
                return(true);
            }
            catch (Exception ex)
            {
                document.Close();
                writer.Close();
                writer.Dispose();
                return(false);
            }
        }
        public static void CrearOrdenServicio(bool MostrarPrecio,
                                              List <ServiceOrderPdf> ListaServiceOrder,
                                              OrganizationCustom infoEmpresaPropietaria,
                                              string EmpresaCliente,
                                              string ServiceOrderId,
                                              string Fecha,
                                              string Usuario,
                                              string filePDF)
        {
            Document document = new Document(PageSize.A4, 30f, 30f, 45f, 41f);

            document.SetPageSize(iTextSharp.text.PageSize.A4);


            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables

            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.White);
            string          include      = string.Empty;
            List <PdfPCell> cells        = null;
            float[]         columnWidths = null;
            //string[] columnValues = null;
            string[] columnHeaders = null;


            PdfPTable filiationWorker = new PdfPTable(8);

            PdfPTable table = null;

            PdfPCell cell = null;

            #endregion

            #region Fonts

            Font fontTitle1               = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 9, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue     = FontFactory.GetFont("Calibri", 11, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold = FontFactory.GetFont("Calibri", 11, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue1     = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold1 = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValueNegrita = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontAptitud = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion
            var tamaño_celda = 20f;

            #region PRIMERA PÁGINA
            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresaPropietaria.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            iTextSharp.text.Image imagenfirma = iTextSharp.text.Image.GetInstance("C:/Banner/GetImageText.jpg");
            imagenfirma.ScalePercent(100);
            imagenfirma.SetAbsolutePosition(200, 200);
            document.Add(imagenfirma);
            #endregion
            #region Contenido
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);
            document.Add(table);

            string[] fech = Fecha.ToString().Split(' ');
            string   mes  = null;
            if (fech[2] == "enero")
            {
                mes = "01";
            }
            else if (fech[2] == "febrero")
            {
                mes = "02";
            }
            else if (fech[2] == "marzo")
            {
                mes = "03";
            }
            else if (fech[2] == "abril")
            {
                mes = "04";
            }
            else if (fech[2] == "mayo")
            {
                mes = "05";
            }
            else if (fech[2] == "junio")
            {
                mes = "06";
            }
            else if (fech[2] == "julio")
            {
                mes = "07";
            }
            else if (fech[2] == "agosto")
            {
                mes = "08";
            }
            else if (fech[2] == "setiembre")
            {
                mes = "09";
            }
            else if (fech[2] == "octubre")
            {
                mes = "10";
            }
            else if (fech[2] == "noviembre")
            {
                mes = "11";
            }
            else if (fech[2] == "diciembre")
            {
                mes = "12";
            }

            string anio = fech[4];

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\n" + infoEmpresaPropietaria.v_Sede + ", " + Fecha, fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = PdfPCell.ALIGN_RIGHT, BorderColor = BaseColor.WHITE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Carta N° " + ServiceOrderId.Substring(7, 9) + "-" + mes + "-" + anio.Substring(2, 2) + "-CSLS.R.L./CAL.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("Estimado (s) Sr (s). " + EmpresaCliente, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("ASUNTO: PROPUESTA ECONÓMICA PARA EXAMENES MÉDICOS OCUPACIONALES", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("Estimado (s) Sr (s).", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },


                new PdfPCell(new Phrase("\n\n\t    Es grato dirigirnos a Ud (s). Para saludarlo (s), y a la vez agradecer su preferencia en nuestra ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("institución.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },


                new PdfPCell(new Phrase("\nEn esta oportunidad nos complace hacerles llegar nuestra propuesta técnico económico de nuestros", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\nservicios de Exámenes Médicos Ocupacionales (pre ocupacionales, periódicos, retiro, visita, transcripciones, ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\nexámenes de altura, psicosensométrico, psicológico, otros). Además cabe señalar que nuestra propuesta", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("está sujeta a evaluación", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },


                new PdfPCell(new Phrase("\n\t    " + infoEmpresaPropietaria.v_Name + " agradece su rpeferencia y está a vuestra disposición para iniciar un vínculo laboral duradero.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },


                new PdfPCell(new Phrase("\nNos despedimos quedando a sus gratas órdenes.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("\nAtentamente.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("\nCc. Archivo", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 50, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
            };
            columnWidths    = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);
            document.Add(filiationWorker);
            #endregion
            #region Fecha / Firmma
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, FixedHeight = 180, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(infoEmpresaPropietaria.v_Name, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 15, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Tel. 076 340201 anexo 29", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 15, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Cel. 976220538", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 15, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("*****@*****.**", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 15, BorderColor = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);
            document.Add(table);
            #endregion
            #endregion
            document.NewPage();


            #region SEGUNDA PAGINA
            #region TÍTULO

            if (infoEmpresaPropietaria.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            #endregion
            #region empresa y servicio
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\n\n", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("PROPUESTA ECONOMICA " + EmpresaCliente, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("EVALUACION MEDICO OCUPACIONAL", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("EXAMENES MÉDICOS PRE OCUPACIONAL", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
            };
            columnWidths    = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);
            document.Add(filiationWorker);
            cells = new List <PdfPCell>();
            #region
            #region Parte Dinámica
            cells = new List <PdfPCell>();
            foreach (var Cabecera in ListaServiceOrder)
            {
                cell = new PdfPCell(new Phrase(Cabecera.EmpresaCliente, fontColumnValueNegrita))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                };
                cells.Add(cell);
                var ListaFiltrada = Cabecera.DetalleServiceOrder.FindAll(p => p.v_Precio != 0.00);
                foreach (var Detalle in ListaFiltrada)
                {
                    cell = new PdfPCell(new Phrase(Detalle.Componente, fontColumnValueNegrita))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_RIGHT
                    };
                    cells.Add(cell);
                    string Valor = MostrarPrecio == true?Detalle.v_Precio.ToString() == "0.01" ? "COSTO CERO" : Detalle.v_Precio.ToString() : Detalle.v_Precio.ToString() == "0.01" ? "COSTO CERO" : "";

                    if (Valor != "")
                    {
                        Valor = "S/." + Valor;
                    }

                    cell = new PdfPCell(new Phrase(Valor, fontColumnValueNegrita))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_CENTER
                    };
                    cells.Add(cell);
                }
                cell = new PdfPCell(new Phrase(" ", fontColumnValueNegrita))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_CENTER, Border = PdfPCell.NO_BORDER
                };
                cells.Add(cell);

                cell = new PdfPCell(new Phrase("TOTAL: S/. ", fontColumnValueNegrita))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_RIGHT, Border = PdfPCell.NO_BORDER
                };
                cells.Add(cell);


                cell = new PdfPCell(new Phrase(Cabecera.TotalProtocolo.ToString(), fontColumnValueNegrita))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                };
                cells.Add(cell);

                cell = new PdfPCell(new Phrase("Los precios no incluyen I.G.V.", fontColumnValueNegrita))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_CENTER, Border = PdfPCell.NO_BORDER
                };
                cells.Add(cell);

                cell = new PdfPCell(new Phrase(" ", fontColumnValueNegrita))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_CENTER, Border = PdfPCell.NO_BORDER
                };
                cells.Add(cell);
            }


            columnWidths = new float[] { 50f, 50f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

            document.Add(filiationWorker);
            #endregion

            #endregion
            #endregion
            #endregion

            document.NewPage();
            #region TERCERA HOJA
            #region TÍTULO

            if (infoEmpresaPropietaria.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            #endregion
            #region Texto en duro

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\n\n", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("INTERCONSULTA CON ESPECIALISTAS", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("   -  OFTALMOLOGIA", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("   -  OTORRINOLARINGOLOGIA", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("   -  NUTRICIONISTA", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("   -  MEDICINA INTERNA", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("   -  CARDIOLOGIA", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("   -  TRAUMATOLOGIA", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("   -  NEUMOLOGIA", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("   -  OTROS SEGÚN REQUERIMIENTO", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("NOTA:", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("TODOS LOS COSTOS INCLUYEN IGV", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("\nNUESTROS HORARIOS DE ATENCIÓN", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("Nuestro horario de atención son las 24 horas del día, los 365 días del año en nuestra área asistencial.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("De Lunes a Sábado de 7:30 am a 12 mm, y de 3:00 pm a 7:00 pm en nuestra ára Ocupacional. ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("NÚMERO DE CUENTA:", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 10, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };

            //filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);
            document.Add(filiationWorker);

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("ENTIDAD BANCARIA", fontColumnValueBold1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("NÚMERO DE CUENTA", fontColumnValueBold1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("CUENTA INTERBANCARIA SOLES", fontColumnValueBold1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("NÚMERO DE CUENTA DOLARES", fontColumnValueBold1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("BANCO CONTINENTAL\n(Cuenta Corriente)", fontColumnValueBold1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("0011-0277-0100054539-10", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("011-277-000100054539-10", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("0011-0277-0100054547-13", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("BANCO CONTINENTAL\n(Cuenta de Ahorro)", fontColumnValueBold1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("0011-0277-11-0200278043", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("0011-0277-11-0200278043 11", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("-", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("BANCO DE CREDITO\n(Cuenta Corriente)", fontColumnValueBold1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("245-1810834-0-98", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("002 245 0018 1083 409897", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("-", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("BANCO INTERBANK\n(Cuenta Corriente)", fontColumnValueBold1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("702-3000888410", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("-", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("-", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("", fontColumnValueBold1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("CUENTA DE DETRACCIONES", fontColumnValueBold1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("BANCO DE LA NACION", fontColumnValueBold1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("00-774-002413", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 25f, 25f, 25f, 25f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);

            #endregion
            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
        }
Beispiel #7
0
        public static void Create_Certificado_AptitudMedicoOcupacional(organizationDto infoEmpresa, string filePDF)
        {
            Document document = new Document(PageSize.A4, 50f, 30f, 45f, 41f);

            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include       = string.Empty;
            List <PdfPCell> cells         = null;
            float[]         columnWidths  = null;
            string[]        columnValues  = null;
            string[]        columnHeaders = null;
            PdfPTable       header2       = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            PdfPCell  cell            = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            #region Cabecera

            if (infoEmpresa != null)
            {
                if (infoEmpresa.b_Image != null)
                {
                    iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresa.b_Image));
                    imagenEmpresa.ScalePercent(25);
                    imagenEmpresa.SetAbsolutePosition(40, 790);
                    document.Add(imagenEmpresa);
                }
            }


            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("CERTIFICADO DE APTITUD DE EVALUACIÓN PSICOSENSOMETRICO", fontTitle1))
                {
                    BorderColor = BaseColor.BLACK, BackgroundColor = BaseColor.WHITE, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f
                },

                new PdfPCell(new Phrase("AQUÍ LA RAZÓN SOCIAL", fontTitle1))
                {
                    BorderColor = BaseColor.BLACK, BackgroundColor = BaseColor.WHITE, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f
                },
            };


            columnWidths = new float[] { 50f, 50f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);

            #endregion

            var tamaño_celda = 20f;

            //organizationDto infoEmpresa, PacientList datosPac, string filePDF
            //datosPac.v_FirstLastName + datosPac.v_SecondLastName + ", " + datosPac.v_FirstName
            //datosPac.v_DocNumber
            //datosPac.Edad.ToString()
            //datosPac.Genero
            //datosPac.Empresa

            cells = new List <PdfPCell>
            {
                new PdfPCell(new Phrase())
                {
                    BorderColor = BaseColor.WHITE, Colspan = 1, Rowspan = 12
                },

                new PdfPCell(new Phrase("APELLIDOS Y NOMBRES", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("JASON JOSEPH GUTIERREZ CUADROS", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },


                new PdfPCell(new Phrase("DOC. DE IDENTIDAD", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("74390363", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("EDAD", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("23", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("GÉNERO", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("MASCULINO", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("PUESTO AL QUE POSTULA (Solo pre-ocupacional)", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("PUESTO DE PRUEBA", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("EMPRESA", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("EMPRESA DE PRUEBA", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("OCUPACIÓN ACTUAL O ÚLTIMA OCUPACIÓN", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("DESARROLLADOR", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("TIPO DE SERVICIO", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("MEDICO OCUPACIONAL", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("CONCLUSIÓN DE LA APTITUD MÉDICA:", fontTitle1))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 30f
                },

                new PdfPCell(new Phrase("APTO  (Para el puesto en que trabaja o postula)", fontTitle1))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 30
                },
                new PdfPCell(new Phrase("X", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 30
                },
                new PdfPCell(new Phrase("RESTRICCIONES", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 30
                },

                new PdfPCell(new Phrase("APTO CON RESTRICCIÓN  (Para el puesto en que trabaja o postula)", fontTitle1))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 30
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 30
                },
                new PdfPCell(new Phrase("por verificar", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 4, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE
                },

                new PdfPCell(new Phrase("NO APTO  (Para el puesto en que trabaja o postula)", fontTitle1))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 30
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 30
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 60
                },

                new PdfPCell(new Phrase("RECOMENDACIOENS", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("SELLO Y FIRMA DEL MÉDICO QUE CERTIFICA", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("1.- ESTA ES UNA RECOMENDACIÓN DE PRUEBA", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 100
                },
                new PdfPCell(new Phrase("ESTA ES UNA FIRMA DE PRUEBA", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 100
                },

                new PdfPCell(new Phrase("FECHA DE E.M.O", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 100
                },
                new PdfPCell(new Phrase("15/04/2019", fontColumnValue))
                {
                    BorderColor = BaseColor.BLACK, Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 100
                },

                new PdfPCell(new Phrase())
                {
                    BorderColor = BaseColor.WHITE, Colspan = 1, Rowspan = 12
                },
            };
            columnWidths = new float[] { 5f, 20f, 15f, 10f, 15f, 10f, 20f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);


            document.Close();
            writer.Close();
            writer.Dispose();
        }