public static void CreateCertificadoAptitudCompleto(List <DiagnosticRepositoryList> filiationData, organizationDto infoEmpresaPropietaria, List <DiagnosticRepositoryList> diagnosticRepository, string filePDF, string PathNegro, string PathBlanco)
        {
            //
            // step 1: creation of a document-object
            Document document = new Document();

            //Document document = new Document(new Rectangle(500f, 300f), 10, 10, 10, 10);
            //document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
            document.SetPageSize(iTextSharp.text.PageSize.A4);
            //Document document = new Document(PageSize.A4, 0, 0, 20, 20);
            try
            {
                // step 2: we create a 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 Fonts

                Font fontTitle1               = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, 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.White));
                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, 8, 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(FontFactory.TIMES_ROMAN, 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));


                #endregion

                //#region Logo

                //Image logo = HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image, 30F);
                //PdfPTable headerTbl = new PdfPTable(1);
                //headerTbl.TotalWidth = writer.PageSize.Width;
                //PdfPCell cellLogo = new PdfPCell(logo);

                //cellLogo.VerticalAlignment = Element.ALIGN_TOP;
                //cellLogo.HorizontalAlignment = Element.ALIGN_CENTER;

                //cellLogo.Border = PdfPCell.NO_BORDER;
                //headerTbl.AddCell(cellLogo);
                //document.Add(headerTbl);

                //#endregion

                //#region Title

                //Paragraph cTitle = new Paragraph("CERTIFICADO DE APTITUD MÉDICO OCUPACIONAL", fontTitle2);
                ////Paragraph cTitle2 = new Paragraph(customerOrganizationName, fontTitle2);
                //cTitle.Alignment = Element.ALIGN_CENTER;
                ////cTitle2.Alignment = Element.ALIGN_CENTER;

                //document.Add(cTitle);
                ////document.Add(cTitle2);

                //#endregion

                #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 header1 = new PdfPTable(2);
                //header1.HorizontalAlignment = Element.ALIGN_CENTER;
                //header1.WidthPercentage = 100;
                ////header1.TotalWidth = 500;
                ////header1.LockedWidth = true;    // Esto funciona con TotalWidth
                //float[] widths = new float[] { 150f, 200f};
                //header1.SetWidths(widths);


                //Rectangle rec = document.PageSize;
                PdfPTable header2 = new PdfPTable(6);
                header2.HorizontalAlignment = Element.ALIGN_CENTER;
                header2.WidthPercentage     = 100;
                //header1.TotalWidth = 500;
                //header1.LockedWidth = true;    // Esto funciona con TotalWidth
                float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
                header2.SetWidths(widths1);
                //header2.SetWidthPercentage(widths1, rec);

                PdfPTable companyData = new PdfPTable(6);
                companyData.HorizontalAlignment = Element.ALIGN_CENTER;
                companyData.WidthPercentage     = 100;
                //header1.TotalWidth = 500;
                //header1.LockedWidth = true;    // Esto funciona con TotalWidth
                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;

                #endregion
                document.Add(new Paragraph("\r\n"));
                document.Add(new Paragraph("\r\n"));
                document.Add(new Paragraph("\r\n"));
                document.Add(new Paragraph("\r\n"));
                #region Title
                //List<PdfPCell> cells = null;
                PdfPCell CellLogo = null;
                //float[] columnWidths = null;
                cells = new List <PdfPCell>();
                PdfPCell cellPhoto1 = null;

                if (filiationData[0].b_Photo != null)
                {
                    cellPhoto1 = new PdfPCell(HandlingItextSharp.GetImage(filiationData[0].b_Photo, 23F))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_RIGHT
                    }
                }
                ;
                else
                {
                    cellPhoto1 = new PdfPCell(new Phrase(" ", fontColumnValue))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_RIGHT
                    }
                };

                if (infoEmpresaPropietaria.b_Image != null)
                {
                    CellLogo = new PdfPCell(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image, 30F))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_LEFT
                    };
                }
                else
                {
                    CellLogo = new PdfPCell(new Phrase(" ", fontColumnValue))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_LEFT
                    };
                }

                columnWidths = new float[] { 100f };

                var cellsTit = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("CERTIFICADO DE APTITUD MÉDICO OCUPACIONAL", fontTitle1))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_CENTER
                    },
                };

                table = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);

                cells.Add(CellLogo);
                cells.Add(new PdfPCell(table));
                cells.Add(cellPhoto1);

                columnWidths = new float[] { 20f, 60f, 20f };

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

                #endregion



                // Salto de linea


                string PuestoPostula = "-----";
                string PuestoActual  = "-----";


                if (filiationData[0].i_EsoTypeId == ((int)Sigesoft.Common.TypeESO.PreOcupacional).ToString())
                {
                    PuestoPostula = filiationData[0].v_OccupationName;
                }
                else
                {
                    PuestoActual = filiationData[0].v_OccupationName;
                }

                #region Cabecera del Reporte

                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("APELLIDOS Y NOMBRES:", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT
                    }, new PdfPCell(new Phrase(filiationData[0].v_PersonName, fontColumnValue)),
                    new PdfPCell(new Phrase("N° HS:", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT
                    }, new PdfPCell(new Phrase(filiationData[0].v_ServiceId, fontColumnValue)),
                    new PdfPCell(new Phrase("DOC. DE IDENTIDAD:", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT
                    }, new PdfPCell(new Phrase(filiationData[0].v_DocNumber, fontColumnValue)),
                    new PdfPCell(new Phrase("EDAD:", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT
                    }, new PdfPCell(new Phrase(filiationData[0].i_Age.ToString(), fontColumnValue)),
                    new PdfPCell(new Phrase("EMPRESA:", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT
                    }, new PdfPCell(new Phrase(filiationData[0].v_OrganizationName, fontColumnValue)),
                    new PdfPCell(new Phrase("FECHA DE E.M.O:", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT
                    }, new PdfPCell(new Phrase(filiationData[0].v_ServiceDate, fontColumnValue)),
                    new PdfPCell(new Phrase("PUESTO AL QUE POSTULA:", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT
                    }, new PdfPCell(new Phrase(PuestoPostula, fontColumnValue)),
                    new PdfPCell(new Phrase("FECHA DE NAC.:", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT
                    }, new PdfPCell(new Phrase(filiationData[0].d_BirthDate.Value.ToShortDateString(), fontColumnValue)),
                    new PdfPCell(new Phrase("OCUPACIÓN ACTUAL:", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT
                    }, new PdfPCell(new Phrase(PuestoActual, fontColumnValue)),
                    new PdfPCell(new Phrase("GÉNERO:", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT
                    }, new PdfPCell(new Phrase(filiationData[0].v_GenderName, fontColumnValue)),
                    new PdfPCell(new Phrase("EXAMEN MÉDICO:", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT
                    }, new PdfPCell(new Phrase(filiationData[0].v_EsoTypeName, fontColumnValue))
                    {
                        Colspan = 3
                    },
                    new PdfPCell(new Phrase("GRUPO SANGUÍNEO Y RH:", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT
                    }, new PdfPCell(new Phrase(filiationData[0].GrupoFactorSanguineo, fontColumnValue))
                    {
                        Colspan = 3
                    },
                };

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

                filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, "DATOS GENEREALES", fontTitleTableNegro, null);

                document.Add(filiationWorker);

                #endregion


                // Salto de linea
                document.Add(new Paragraph("\r\n"));


                #region DETALLE EXAMENES
                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("EXAMEN", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    },
                    new PdfPCell(new Phrase("RESULTADO", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    },
                    new PdfPCell(new Phrase("RESTRICCIONES", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    }
                };

                columnWidths = new float[] { 25f, 15f, 60f };

                filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "EXÁMENES REALIZADOS", fontTitleTableNegro, null);

                document.Add(filiationWorker);

                #endregion

                #region Categorias y Restricciones

                cells = new List <PdfPCell>();

                if (filiationData != null && filiationData.Count > 0)
                {
                    columnWidths = new float[] { 30f };
                    include      = "RESULTADO";

                    foreach (var item in filiationData)
                    {
                        cell = new PdfPCell(new Phrase(item.Categoria, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                        cell = new PdfPCell(new Phrase(item.Resultado, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                        cell = new PdfPCell(new Phrase(item.v_RestrictionsName, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }

                    columnWidths = new float[] { 25f, 15f, 60f };
                }
                else
                {
                    cells.Add(new PdfPCell(new Phrase("No se han registrado datos.", fontColumnValue)));
                    columnWidths = new float[] { 100 };
                }

                table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro);

                document.Add(table);

                #endregion


                #region DETALLE CONCLUSIONES
                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("DIAGNÓSTICOS", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    },
                    new PdfPCell(new Phrase("CIE10", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    },
                    new PdfPCell(new Phrase("RECOMENDACIONES", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    }
                };

                columnWidths = new float[] { 20f, 10f, 70f };

                filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "CONCLUSIONES", fontTitleTableNegro, null);

                document.Add(filiationWorker);

                #endregion

                #region Hallazgos y recomendaciones

                cells = new List <PdfPCell>();

                var DxNODescartados = diagnosticRepository.FindAll(p => p.i_FinalQualificationId != (int)Sigesoft.Common.FinalQualification.Descartado);
                if (DxNODescartados != null && DxNODescartados.Count > 0)
                {
                    columnWidths = new float[] { 0.7f, 23.6f };
                    include      = "i_Item,v_RecommendationName";

                    foreach (var item in DxNODescartados)
                    {
                        cell = new PdfPCell(new Phrase(item.v_DiseasesName, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                        cell = new PdfPCell(new Phrase(item.i_DiagnosticTypeId == (int)Sigesoft.Common.TipoDx.Normal?"---": item.v_Dx_CIE10, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                        // Crear tabla de recomendaciones para insertarla en la celda que corresponde
                        table = HandlingItextSharp.GenerateTableFromList(item.Recomendations, columnWidths, include, fontColumnValue);
                        cell  = new PdfPCell(table);
                        cells.Add(cell);
                    }

                    columnWidths = new float[] { 20f, 10f, 70f };
                }
                else
                {
                    cells.Add(new PdfPCell(new Phrase("No se han registrado datos.", fontColumnValue)));
                    columnWidths = new float[] { 100 };
                }

                table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro);

                document.Add(table);

                #endregion

                #region APTITUD

                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("APTO", fontSubTitleNegroNegrita))
                    {
                        Colspan = 2, HorizontalAlignment = Element.ALIGN_CENTER
                    },
                    new PdfPCell(new Phrase("OBSERVADO", fontSubTitleNegroNegrita))
                    {
                        Rowspan = 2, HorizontalAlignment = Element.ALIGN_CENTER
                    },
                    new PdfPCell(new Phrase("NO APTO", fontSubTitleNegroNegrita))
                    {
                        Rowspan = 2, HorizontalAlignment = Element.ALIGN_CENTER
                    },

                    new PdfPCell(new Phrase("SIN RESTRICCIONES", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    },
                    new PdfPCell(new Phrase("CON RESTRICCIONES", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    },

                    new PdfPCell(new Phrase(" ", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Border = PdfPCell.LEFT_BORDER
                    },
                    new PdfPCell(new Phrase(" ", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Border = PdfPCell.LEFT_BORDER
                    },
                    new PdfPCell(new Phrase(" ", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Border = PdfPCell.LEFT_BORDER
                    },
                    new PdfPCell(new Phrase(" ", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    },


                    new PdfPCell(HandlingItextSharp.GetImage(filiationData[0].i_AptitudeStatusId == 2 ?PathNegro :PathBlanco, 30, 7))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Border = PdfPCell.LEFT_BORDER
                    },
                    new PdfPCell(HandlingItextSharp.GetImage(filiationData[0].i_AptitudeStatusId == 5 ?PathNegro :PathBlanco, 30, 7))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Border = PdfPCell.LEFT_BORDER
                    },
                    new PdfPCell(HandlingItextSharp.GetImage(filiationData[0].i_AptitudeStatusId == 4 ?PathNegro :PathBlanco, 30, 7))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Border = PdfPCell.LEFT_BORDER
                    },
                    new PdfPCell(HandlingItextSharp.GetImage(filiationData[0].i_AptitudeStatusId == 3 ?PathNegro :PathBlanco, 30, 7))
                    {
                        Rowspan = 2, HorizontalAlignment = Element.ALIGN_CENTER
                    },


                    new PdfPCell(new Phrase(" ", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Border = PdfPCell.LEFT_BORDER
                    },
                    new PdfPCell(new Phrase(" ", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Border = PdfPCell.LEFT_BORDER
                    },
                    new PdfPCell(new Phrase(" ", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Border = PdfPCell.LEFT_BORDER
                    },


                    new PdfPCell(new Phrase(" ", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Border = PdfPCell.TOP_BORDER
                    },
                    new PdfPCell(new Phrase(" ", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Border = PdfPCell.TOP_BORDER
                    },
                    new PdfPCell(new Phrase(" ", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Border = PdfPCell.TOP_BORDER
                    },
                    new PdfPCell(new Phrase(" ", fontSubTitleNegroNegrita))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Border = PdfPCell.TOP_BORDER
                    }
                };

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

                filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "FUE CONSIDERADO EN ÉSTA OPORTUNIDAD", fontTitleTableNegro, null);

                document.Add(filiationWorker);



                #endregion


                //ServiceComponentList lab = null;
                #region Firma y sello Médico

                table = new PdfPTable(2);

                table.HorizontalAlignment = Element.ALIGN_RIGHT;
                table.WidthPercentage     = 40;

                columnWidths = new float[] { 15f, 25f };
                table.SetWidths(columnWidths);

                PdfPCell cellFirma = null;

                if (filiationData != null)
                {
                    if (filiationData[0].g_Image != null)
                    {
                        cellFirma = new PdfPCell(HandlingItextSharp.GetImage(filiationData[0].g_Image, null, null, 70, 40));
                    }
                    else
                    {
                        cellFirma = new PdfPCell(new Phrase(" ", fontColumnValue));
                    }
                }
                else
                {
                    cellFirma = new PdfPCell();
                }

                cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
                cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cellFirma.FixedHeight         = 70F;

                cell = new PdfPCell(new Phrase("FIRMA Y SELLO MÉDICO", fontColumnValue));
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                table.AddCell(cell);
                table.AddCell(cellFirma);

                document.Add(table);

                #endregion

                // step 5: we close the document
                document.Close();
                writer.Close();
                writer.Dispose();
                //RunFile(filePDF);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public static void CreateFichaMedicaTrabajador3(PacientList filiationData, ServiceList doctoPhisicalExam, List <DiagnosticRepositoryList> diagnosticRepository, organizationDto infoEmpresaPropietaria, string pstrExamenesConcatenados, string pstrExamenesLabConcatenados, List <ServiceComponentList> serviceComponent, string pstrRestriciones, 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();

            page.Dato = "FMT3/" + filiationData.v_FirstName + " " + filiationData.v_FirstLastName + " " + filiationData.v_SecondLastName;
            //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("Arial", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Arial", 9, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableAntecedentesOcupacionales  = FontFactory.GetFont("Arial", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueAntecedentesOcupacionales = FontFactory.GetFont("Arial", 6, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueNegrita = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontAptitud = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            //Font fontTitleTableNegro = FontFactory.GetFont("Arial", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            #endregion


            //#region Logo
            PdfPCell CellLogo = null;


            #region Title

            CellLogo = null;
            cells    = new List <PdfPCell>();
            PdfPCell cellPhoto1 = null;

            if (filiationData.b_Photo != null)
            {
                cellPhoto1 = new PdfPCell(HandlingItextSharp.GetImage(filiationData.b_Photo, 23F))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_RIGHT
                }
            }
            ;
            else
            {
                cellPhoto1 = new PdfPCell(new Phrase(" ", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_RIGHT
                }
            };

            if (infoEmpresaPropietaria.b_Image != null)
            {
                CellLogo = new PdfPCell(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image, 30F))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                };
            }
            else
            {
                CellLogo = new PdfPCell(new Phrase(" ", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                };
            }

            columnWidths = new float[] { 100f };

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("RESUMEN DE EXAMEN MÉDICO", fontTitle1))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
            };

            table = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);

            cells.Add(CellLogo);
            cells.Add(new PdfPCell(table));
            cells.Add(cellPhoto1);

            columnWidths = new float[] { 20f, 60f, 20f };

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

            #endregion

            #region Datos del examen

            cells = new List <PdfPCell>()
            {
                //fila
                new PdfPCell(new Phrase("NRO DE HCL:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.v_IdService, fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("TIPO DE EXAMEN: ", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.v_TipoExamen, fontColumnValue)),
                new PdfPCell(new Phrase("FECHA EXAMEN:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.d_ServiceDate.Value.ToShortDateString(), fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },


                //fila
                new PdfPCell(new Phrase("PROVEEDOR:", fontColumnValue)),
                new PdfPCell(new Phrase(infoEmpresaPropietaria.v_Name, fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("EMPRESA:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.v_OrganitationName, fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("GRUPO DE RIESGO:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.GESO, fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },

                //fila
                new PdfPCell(new Phrase("EXÁMENES REALIZADOS:", fontColumnValue)),
                new PdfPCell(new Phrase(pstrExamenesConcatenados, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },

                //fila
                new PdfPCell(new Phrase("LABORATORIO: ", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase(pstrExamenesLabConcatenados, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
            };
            columnWidths = new float[] { 25f, 20f, 20f, 20f, 20f, 20f };

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

            document.Add(filiationWorker);



            #endregion

            #region Datos del trabajador

            cells = new List <PdfPCell>()
            {
                //fila
                new PdfPCell(new Phrase("APELLIDOS Y NOMBRES:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.v_FirstLastName + " " + filiationData.v_SecondLastName + " " + filiationData.v_FirstName, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },

                //fila
                new PdfPCell(new Phrase("DNI:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.v_DocNumber, fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("EDAD:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.i_Age.Value.ToString(), fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("PUESTO:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.v_CurrentOccupation, fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
            };
            columnWidths = new float[] { 25f, 20f, 10f, 10f, 10f, 50f };

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

            document.Add(filiationWorker);



            #endregion

            #region Resultados del examen médico
            cells = new List <PdfPCell>();

            if (diagnosticRepository != null && diagnosticRepository.Count > 0)
            {
                //PdfPCell cellDx = null;

                columnWidths = new float[] { 50f };
                include      = "v_RecommendationName";

                var ListaFinal = diagnosticRepository.FindAll(p => p.i_CategoryId != 1 && p.i_CategoryId != 10);
                foreach (var item in ListaFinal)
                {
                    if (item.v_DiseasesId == "N009-DD000000029")
                    {
                        cell = new PdfPCell(new Phrase(""))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }
                    else
                    {
                        cell = new PdfPCell(new Phrase(item.Categoria + " - " + item.v_DiseasesName, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }

                    // Crear tabla de recomendaciones para insertarla en la celda que corresponde
                    var tableDx = HandlingItextSharp.GenerateTableFromList(item.Recomendations, columnWidths, include, fontColumnValue);
                    cell = new PdfPCell(tableDx);
                    cells.Add(cell);
                }
                columnWidths = new float[] { 50f, 54f };
            }
            else
            {
                cells.Add(new PdfPCell(new Phrase("No se han registrado datos.", fontColumnValue)));
                columnWidths = new float[] { 100f };
            }

            var GrillaDx = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "RESULTADOS DEL EXAMEN MÉDICO", fontTitleTableNegro);
            document.Add(GrillaDx);
            #endregion

            #region Nutrición
            cells = new List <PdfPCell>();
            var xNutricion = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.ANTROPOMETRIA_ID);
            if (xNutricion != null)
            {
                // Subtitulo  ******************
                cell = new PdfPCell(new Phrase("NUTRICIÓN", fontSubTitleNegroNegrita))
                {
                    Colspan             = 4,
                    BackgroundColor     = subTitleBackGroundColor,
                    HorizontalAlignment = Element.ALIGN_CENTER,
                };

                cells.Add(cell);
                //*****************************************
                // titulo
                var valorPeso  = xNutricion.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.ANTROPOMETRIA_PESO_ID);
                var valorTalla = xNutricion.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.ANTROPOMETRIA_TALLA_ID);
                cells.Add(new PdfPCell(new Phrase("PESO(Kg):", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(valorPeso == null ? string.Empty : valorPeso.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("TALLA(m):", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(valorTalla == null ? string.Empty : valorTalla.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });

                // titulo
                cells.Add(new PdfPCell(new Phrase("EXAMEN", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("VALOR HALLADO", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("DIAGNÓSTICO", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("RECOMENDACIONES", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });

                var valorIMC = xNutricion.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.ANTROPOMETRIA_IMC_ID);

                var dxIMC   = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.ANTROPOMETRIA_IMC_ID);
                var RecoIMC = dxIMC.Recomendations.FindAll(p => p.v_ComponentId == Sigesoft.Common.Constants.ANTROPOMETRIA_ID);
                // 1era fila
                cells.Add(new PdfPCell(new Phrase("IMC", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(valorIMC == null ? string.Empty : valorIMC.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxIMC == null ? "NORMAL" : dxIMC.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(string.Join(", ", RecoIMC.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });

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

                table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths);
                document.Add(table);
            }

            #endregion

            #region Presión Arterial
            cells = new List <PdfPCell>();
            var xPresionArterial = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.FUNCIONES_VITALES_ID);
            if (xPresionArterial != null)
            {
                // Subtitulo  ******************
                cell = new PdfPCell(new Phrase("PRESIÓN ARTERIAL", fontSubTitleNegroNegrita))
                {
                    Colspan             = 4,
                    BackgroundColor     = subTitleBackGroundColor,
                    HorizontalAlignment = Element.ALIGN_CENTER,
                };

                cells.Add(cell);
                //*****************************************

                // titulo
                cells.Add(new PdfPCell(new Phrase("EXAMEN", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("VALOR HALLADO", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("DIAGNÓSTICO", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("RECOMENDACIONES", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });

                var valorPA1 = xPresionArterial.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_PAS_ID) == null ? "" : xPresionArterial.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_PAS_ID).v_Value1;
                var valorPA2 = xPresionArterial.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_PAD_ID) == null ? "" : xPresionArterial.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_PAD_ID).v_Value1;

                var dxPA   = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_PAS_ID);
                var RecoPA = dxPA == null?null: dxPA.Recomendations;
                // 1era fila
                cells.Add(new PdfPCell(new Phrase("PRESIÓN ARTERIAL", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(valorPA1 + " / " + valorPA2, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxPA == null ? "NORMAL" : dxPA.v_Name, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoPA == null ?"CONTROL ANUAL":string.Join(", ", RecoPA.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });

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

                table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths);
                document.Add(table);
            }
            #endregion

            #region Laboratorio
            cells = new List <PdfPCell>();
            // Subtitulo  ******************
            cell = new PdfPCell(new Phrase("LABORATORIO", fontSubTitleNegroNegrita))
            {
                Colspan             = 4,
                BackgroundColor     = subTitleBackGroundColor,
                HorizontalAlignment = Element.ALIGN_CENTER,
            };

            cells.Add(cell);
            //*****************************************

            // titulo
            cells.Add(new PdfPCell(new Phrase("EXAMEN", fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_CENTER
            });
            cells.Add(new PdfPCell(new Phrase("VALOR HALLADO", fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_CENTER
            });
            cells.Add(new PdfPCell(new Phrase("DIAGNÓSTICO", fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_CENTER
            });
            cells.Add(new PdfPCell(new Phrase("RECOMENDACIONES", fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_CENTER
            });

            var xHB = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.HEMOGRAMA_COMPLETO_ID);

            var xHTO            = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.HEMOGRAMA_COMPLETO_ID);
            var xColesterol     = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.COLESTEROL_ID);
            var xTrigli         = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.TRIGLICERIDOS_ID);
            var xGlucosa        = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.GLUCOSA_ID);
            var xUrea           = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.UREA_ID);
            var xCreatina       = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.CREATININA_ID);
            var xColesterol_1   = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.PERFIL_LIPIDICO);
            var xTrigli_1       = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.PERFIL_LIPIDICO);
            var xOrina          = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.EXAMEN_COMPLETO_DE_ORINA_ID);
            var xGrupoSanguineo = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.GRUPO_Y_FACTOR_SANGUINEO_ID);
            if (xHB != null)
            {
                var hbValor = xHB.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.HEMOGRAMA_COMPLETO_HEMOGLOBINA);
                var dxHB    = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.HEMOGRAMA_COMPLETO_HEMOGLOBINA);
                var RecoHB  = dxHB == null ? null : dxHB.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("HB", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxHB == null ? "NORMAL" : dxHB.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }

            if (xHTO != null)
            {
                var hbValor = xHTO.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.HEMOGRAMA_COMPLETO_HEMATOCRITO);
                var dxHTO   = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.HEMOGRAMA_COMPLETO_HEMATOCRITO);
                var RecoHB  = dxHTO == null ? null : dxHTO.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("HTO", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxHTO == null ? "NORMAL" : dxHTO.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }
            if (xColesterol != null)
            {
                var hbValor      = xColesterol.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.COLESTEROL_COLESTEROL_TOTAL_ID);
                var dxColesterol = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.COLESTEROL_COLESTEROL_TOTAL_ID);
                var RecoHB       = dxColesterol == null ? null : dxColesterol.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("COLESTEROL", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxColesterol == null ? "NORMAL" : dxColesterol.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }
            if (xTrigli != null)
            {
                var hbValor  = xTrigli.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.TRIGLICERIDOS_BIOQUIMICA_TRIGLICERIDOS);
                var dxTrigli = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.TRIGLICERIDOS_BIOQUIMICA_TRIGLICERIDOS);
                var RecoHB   = dxTrigli == null ? null : dxTrigli.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("TRIGLICÉRIDOS", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxTrigli == null ? "NORMAL" : dxTrigli.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }
            if (xGlucosa != null)
            {
                var hbValor   = xGlucosa.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.OFTALMOLOGIA_DESCRIPCION);
                var dxGlucosa = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.OFTALMOLOGIA_DESCRIPCION);
                var RecoHB    = dxGlucosa == null ? null : dxGlucosa.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("GLUCOSA", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxGlucosa == null ? "NORMAL" : dxGlucosa.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }
            if (xUrea != null)
            {
                var hbValor = xUrea.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.UREA_BIOQUIMICA_UREA);
                var dxUrea  = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.UREA_BIOQUIMICA_UREA);
                var RecoHB  = dxUrea == null ? null : dxUrea.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("ÚREA", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxUrea == null ? "NORMAL" : dxUrea.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }
            if (xCreatina != null)
            {
                var hbValor    = xCreatina.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CREATININA_BIOQUIMICA_CREATININA);
                var dxCreatina = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CREATININA_BIOQUIMICA_CREATININA);
                var RecoHB     = dxCreatina == null ? null : dxCreatina.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("CREATINA", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxCreatina == null ? "NORMAL" : dxCreatina.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }
            if (xColesterol_1 != null)
            {
                var hbValor        = xColesterol_1.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.COLESTEROL_TOTAL);
                var dxColesterol_1 = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.COLESTEROL_TOTAL);
                var RecoHB         = dxColesterol_1 == null ? null : dxColesterol_1.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("COLESTEROL", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxColesterol_1 == null ? "NORMAL" : dxColesterol_1.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }
            if (xTrigli_1 != null)
            {
                var hbValor    = xTrigli_1.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.TRIGLICERIDOS);
                var dxTrigli_1 = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.TRIGLICERIDOS);
                var RecoHB     = dxTrigli_1 == null ? null : dxTrigli_1.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("TRIGLICÉRIDOS", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxTrigli_1 == null ? "NORMAL" : dxTrigli_1.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }

            if (xOrina != null)
            {
                var dxOrina = diagnosticRepository.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.EXAMEN_COMPLETO_DE_ORINA_ID);
                var RecoHB  = dxOrina == null ? null : dxOrina.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("EXAMEN ORINA", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase("---", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxOrina == null ? "NORMAL" : dxOrina.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }

            if (xGrupoSanguineo != null)
            {
                var GSValor = xGrupoSanguineo.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.GRUPO_SANGUINEO_ID);
                var FSValor = xGrupoSanguineo.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FACTOR_SANGUINEO_ID);

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("GRUPO SANGUÍNEO", fontSubTitleNegroNegrita)));
                cells.Add(new PdfPCell(new Phrase(GSValor == null ? string.Empty : GSValor.v_Value1Name, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("---", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("---", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });

                cells.Add(new PdfPCell(new Phrase("FACTOR RH", fontSubTitleNegroNegrita)));
                cells.Add(new PdfPCell(new Phrase(FSValor == null ? string.Empty : FSValor.v_Value1Name, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("---", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("---", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }

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

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths);
            document.Add(table);



            #endregion

            #region GrupoSanguineo

            #endregion

            #region Aptitud
            cells = new List <PdfPCell>()
            {
                //fila
                new PdfPCell(new Phrase("APTO:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.i_AptitudeStatusId == (int)Sigesoft.Common.AptitudeStatus.Apto ? "X" :"", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("APTO CON RESTRICCIÓN: ", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.i_AptitudeStatusId == (int)Sigesoft.Common.AptitudeStatus.AptRestriccion ? "X" :"", fontColumnValue)),
                new PdfPCell(new Phrase("NO APTO:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.i_AptitudeStatusId == (int)Sigesoft.Common.AptitudeStatus.NoApto ? "X" :"", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("OBSERVADO:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.i_AptitudeStatusId == (int)Sigesoft.Common.AptitudeStatus.AptoObs ? "X" :"", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },

                //fila
                new PdfPCell(new Phrase("COMENTARIOS:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.v_ObsStatusService == "" ? "NINGUNO":filiationData.v_ObsStatusService, fontColumnValue))
                {
                    Colspan = 7, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },

                //fila
                new PdfPCell(new Phrase("RESTRICCIONES:", fontColumnValue)),
                new PdfPCell(new Phrase(pstrRestriciones == "" ? "NINGUNA" : pstrRestriciones, fontColumnValue))
                {
                    Colspan = 7, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
            };
            columnWidths = new float[] { 20f, 10f, 20f, 10f, 20f, 10f, 20f, 10f };

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

            document.Add(filiationWorker);

            #endregion

            #region Firma y sello Médico

            table = new PdfPTable(2);
            table.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.WidthPercentage     = 40;

            columnWidths = new float[] { 15f, 25f };
            table.SetWidths(columnWidths);

            PdfPCell cellFirma = null;

            if (filiationData.FirmaDoctorAuditor != null)
            {
                cellFirma = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaDoctorAuditor, null, null, 120, 45));
            }
            else
            {
                cellFirma = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirma.FixedHeight         = 50F;

            cell = new PdfPCell(new Phrase("FIRMA Y SELLO MÉDICO", fontColumnValue));
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;

            table.AddCell(cell);
            table.AddCell(cellFirma);

            document.Add(table);

            #endregion



            document.Close();
            writer.Close();
            writer.Dispose();
        }
    }
        public static void CreateFichaMedicaTrabajador2(PacientList filiationData, ServiceList doctoPhisicalExam, List <DiagnosticRepositoryList> diagnosticRepository, organizationDto infoEmpresaPropietaria, 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();

            page.Dato = "FMT2/" + filiationData.v_FirstName + " " + filiationData.v_FirstLastName + " " + filiationData.v_SecondLastName;
            //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("Arial", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Arial", 9, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableAntecedentesOcupacionales  = FontFactory.GetFont("Arial", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueAntecedentesOcupacionales = FontFactory.GetFont("Arial", 6, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueNegrita = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontAptitud = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            //Font fontTitleTableNegro = FontFactory.GetFont("Arial", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            #endregion


            //#region Logo
            PdfPCell CellLogo = null;
            //if (infoEmpresaPropietaria.b_Image != null)
            //{
            //    CellLogo = new PdfPCell(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image, 30F));
            //}
            //else
            //{
            //    CellLogo = new PdfPCell(new Phrase(" ", fontColumnValue));
            //}
            //Image logo = HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image, 20F);
            //PdfPTable headerTbl = new PdfPTable(1);
            //headerTbl.TotalWidth = writer.PageSize.Width;
            //PdfPCell cellLogo = new PdfPCell(CellLogo);

            //cellLogo.VerticalAlignment = Element.ALIGN_TOP;
            //cellLogo.HorizontalAlignment = Element.ALIGN_CENTER;

            //cellLogo.Border = PdfPCell.NO_BORDER;
            //headerTbl.AddCell(cellLogo);
            //document.Add(headerTbl);

            //#endregion

            //document.Add(new Paragraph("\r\n"));

            //#region Title
            //Paragraph cTitle = new Paragraph("CARTA DE COMPROMISO", fontTitle1);
            //cTitle.Alignment = Element.ALIGN_CENTER;
            //document.Add(cTitle);
            //#endregion

            #region Title

            CellLogo = null;
            cells    = new List <PdfPCell>();
            PdfPCell cellPhoto1 = null;

            if (filiationData.b_Photo != null)
            {
                cellPhoto1 = new PdfPCell(HandlingItextSharp.GetImage(filiationData.b_Photo, 23F))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_RIGHT
                }
            }
            ;
            else
            {
                cellPhoto1 = new PdfPCell(new Phrase(" ", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_RIGHT
                }
            };

            if (infoEmpresaPropietaria.b_Image != null)
            {
                CellLogo = new PdfPCell(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image, 30F))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                };
            }
            else
            {
                CellLogo = new PdfPCell(new Phrase(" ", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                };
            }

            columnWidths = new float[] { 100f };

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("CARTA DE COMPROMISO", fontTitle1))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
            };

            table = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);

            cells.Add(CellLogo);
            cells.Add(new PdfPCell(table));
            cells.Add(cellPhoto1);

            columnWidths = new float[] { 20f, 60f, 20f };

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

            #endregion
            #region Cabecera
            string XPreocupacional = "( )";
            string PeriodicoAnual  = "( )";
            string Retiro          = "( )";
            if (filiationData.i_EsoTypeId == (int)Sigesoft.Common.TypeESO.PreOcupacional)
            {
                XPreocupacional = "( X )";
            }
            else if (filiationData.i_EsoTypeId == (int)Sigesoft.Common.TypeESO.PeriodicoAnual)
            {
                PeriodicoAnual = "( X )";
            }
            else if (filiationData.i_EsoTypeId == (int)Sigesoft.Common.TypeESO.Retiro)
            {
                Retiro = "( X )";
            }
            string Linea1 = "YO,        " + filiationData.v_OwnerName.ToUpper();

            string Linea2 = "IDENTIFICADO CON DNI/CE/PASAPORTE       " + filiationData.v_DocNumber + ",         CON EL CARGO / PUESTO " + filiationData.v_CurrentOccupation == null ? "" : filiationData.v_CurrentOccupation;

            string Linea3 = "PERTENECIENTE A LA EMPRESA        " + filiationData.v_FullWorkingOrganizationName.ToUpper();

            string Linea4 = "EN EL CENTRO MÉDICO:        " + infoEmpresaPropietaria.v_Name.ToUpper() + ",         EN LA FECHA:" + filiationData.d_ServiceDate.Value.ToShortDateString();

            cells = new List <PdfPCell>()
            {
                //fila
                new PdfPCell(new Phrase(Linea1, fontColumnValue))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_JUSTIFIED
                },

                //fila
                new PdfPCell(new Phrase(Linea2, fontColumnValue))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_JUSTIFIED
                },

                //fila
                new PdfPCell(new Phrase(Linea3, fontColumnValue))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_JUSTIFIED
                },

                //fila
                new PdfPCell(new Phrase("HABIENDO PASADO LA EVALUACIÓN MÉDICA:", fontTitleTable))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },

                //fila
                new PdfPCell(new Phrase(XPreocupacional, fontColumnValue))
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("PRE OCUPACIONAL", fontColumnValue))
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase(PeriodicoAnual, fontColumnValue))
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("ANUAL", fontColumnValue))
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase(Retiro, fontColumnValue))
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("DE RETIRO", fontColumnValue))
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },

                //fila
                new PdfPCell(new Phrase(Linea4, fontColumnValue))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },

                //fila
                new PdfPCell(new Phrase("HE SIDO DEBIDAMENTE INFORMADO DE LOS RESULTADOS OBTENIDOS EN EL EXAMEN MÉDICO, SIENDO LOS DIAGNÓSTICOS ENCONTRADOS:", fontColumnValue))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
            };

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

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

            document.Add(filiationWorker);

            #endregion


            #region DETALLE CONCLUSIONES
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("ÍTEM", fontSubTitleNegroNegrita))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("DIAGNÓSTICOS", fontSubTitleNegroNegrita))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("CIE10", fontSubTitleNegroNegrita))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                },
            };

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

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);

            document.Add(filiationWorker);

            #endregion

            #region Hallazgos y recomendaciones

            cells = new List <PdfPCell>();

            int nro = 1;
            var dx  = diagnosticRepository.FindAll(p => p.i_DiagnosticTypeId != (int)Sigesoft.Common.TipoDx.Normal);
            if (dx != null && dx.Count > 0)
            {
                //columnWidths = new float[] { 0.7f, 23.6f };
                //include = "i_Item,v_RecommendationName";

                foreach (var item in dx)
                {
                    cell = new PdfPCell(new Phrase(nro.ToString() + ".- ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                    };
                    cells.Add(cell);

                    cell = new PdfPCell(new Phrase(item.v_DiseasesName, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE
                    };
                    cells.Add(cell);
                    cell = new PdfPCell(new Phrase(item.i_DiagnosticTypeId == (int)Sigesoft.Common.TipoDx.Normal ? "---" : item.v_Dx_CIE10, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                    };
                    cells.Add(cell);
                    //// Crear tabla de recomendaciones para insertarla en la celda que corresponde
                    //table = HandlingItextSharp.GenerateTableFromList(item.Recomendations, columnWidths, include, fontColumnValue);
                    //cell = new PdfPCell(table);
                    //cells.Add(cell);
                    nro++;
                }

                columnWidths = new float[] { 5f, 80f, 15f };
            }
            else
            {
                cells.Add(new PdfPCell(new Phrase("No se han registrado datos.", fontColumnValue)));
                columnWidths = new float[] { 100 };
            }

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro);

            document.Add(table);

            #endregion

            #region Texto
            cells = new List <PdfPCell>()
            {
                //fila
                new PdfPCell(new Phrase("LOS MISMOS QUE ACEPTO Y POR LO TANTO ME COMPROMETO A SEGUIR LAS SIGUIENTES RECOMENDACIONES CLÍNICAS Y DE SALUD OCUPACIONAL QUE EL MÉDICO CONSIDERE.", fontColumnValue))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
            };

            columnWidths = new float[] { 100f };

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

            document.Add(filiationWorker);
            #endregion

            #region Recomendaciones

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("ÍTEM", fontSubTitleNegroNegrita))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("RECOMENDACIONES", fontSubTitleNegroNegrita))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                },
            };

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

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);

            document.Add(filiationWorker);


            cells = new List <PdfPCell>();

            int nroreco = 1;
            if (dx != null && dx.Count > 0)
            {
                foreach (var item in dx)
                {
                    columnWidths = new float[] { 95f };
                    include      = "v_RecommendationName";

                    cell = new PdfPCell(new Phrase(nroreco.ToString() + ".- ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                    };
                    cells.Add(cell);

                    table = HandlingItextSharp.GenerateTableFromList(item.Recomendations, columnWidths, include, fontColumnValue);
                    cell  = new PdfPCell(table);
                    cells.Add(cell);
                    nroreco++;
                }

                columnWidths = new float[] { 5f, 95f };
            }
            else
            {
                cells.Add(new PdfPCell(new Phrase("No se han registrado datos.", fontColumnValue)));
                columnWidths = new float[] { 100 };
            }

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro);

            document.Add(table);


            #endregion

            #region Restricciones

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("ÍTEM", fontSubTitleNegroNegrita))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("RESTRICCIONES", fontSubTitleNegroNegrita))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                },
            };

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

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);

            document.Add(filiationWorker);


            cells = new List <PdfPCell>();

            int nroreco1 = 1;
            if (dx != null && dx.Count > 0)
            {
                foreach (var item in dx)
                {
                    if (item.Restrictions.Count > 0)
                    {
                        columnWidths = new float[] { 95f };
                        include      = "v_RestrictionName";

                        cell = new PdfPCell(new Phrase(nroreco1.ToString() + ".- ", fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);

                        //cell = new PdfPCell(new Phrase(item.v_DiseasesName, fontColumnValue)) { HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE };
                        //cells.Add(cell);
                        //cell = new PdfPCell(new Phrase(item.i_DiagnosticTypeId == (int)Sigesoft.Common.TipoDx.Normal ? "---" : item.v_Dx_CIE10, fontColumnValue)) { HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE };
                        //cells.Add(cell);


                        // Crear tabla de recomendaciones para insertarla en la celda que corresponde

                        table = HandlingItextSharp.GenerateTableFromList(item.Restrictions, columnWidths, include, fontColumnValue);
                        cell  = new PdfPCell(table);
                        cells.Add(cell);
                        nroreco1++;
                    }
                }

                columnWidths = new float[] { 5f, 95f };
            }
            else
            {
                cells.Add(new PdfPCell(new Phrase("No se han registrado datos.", fontColumnValue)));
                columnWidths = new float[] { 100 };
            }

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro);

            document.Add(table);


            #endregion

            #region Texto
            cells = new List <PdfPCell>()
            {
                //fila
                new PdfPCell(new Phrase("LAS QUE CUMPLIRÉ ESTRICTAMENTE CON LA FINALIDAD DE PREVENIR LA SEVERIDAD O EMPEORAMIENTO DE LOS PRESENTES CUADROS DIAGNOSTICADOS,  ASÍ MISMO  ME COMPROMETO A CUMPLIR CON LOS CHEQUEOS Y CONTROLES MÉDICOS OCUPACIONALES QUE EL  MÉDICO DE LA CLÍNICA MENCIONADA  INDIQUE.", fontColumnValue))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                //fila
                new PdfPCell(new Phrase("FIRMO EN CONFORMIDAD CON LO ANTES EXPUESTO.", fontColumnValue))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
            };

            columnWidths = new float[] { 100f };

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

            document.Add(filiationWorker);
            #endregion

            document.Add(new Paragraph("\r\n"));
            #region Firma

            #region Creando celdas de tipo Imagen y validando nulls

            // Firma del trabajador ***************************************************
            PdfPCell cellFirmaTrabajador = null;

            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, 20, 10));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase("Sin Firma Trabajador", fontColumnValue));
            }

            // Huella del trabajador **************************************************
            PdfPCell cellHuellaTrabajador = null;

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, 20, 30));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase("Sin Huella", fontColumnValue));
            }

            // Firma del doctor EXAMEN FISICO **************************************************

            PdfPCell cellFirma = null;

            if (filiationData == null)
            {
                cellFirma = new PdfPCell(new Phrase("Sin Firma", fontColumnValue));
            }
            else if (filiationData.FirmaDoctorAuditor != null)
            {
                cellFirma = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaDoctorAuditor, null, null, 120, 45));
            }
            else
            {
                cellFirma = new PdfPCell(new Phrase("Sin Firma", fontColumnValue));
            }
            #endregion

            #region Crear tablas en duro (para la Firma y huella del trabajador)

            cells = new List <PdfPCell>();

            cellFirmaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirmaTrabajador.FixedHeight         = 80F;
            cells.Add(cellFirmaTrabajador);
            cells.Add(new PdfPCell(new Phrase("NOMBRE: " + filiationData.v_OwnerName, fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE
            });
            cells.Add(new PdfPCell(new Phrase("D.N.I: " + filiationData.v_DocNumber, fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE
            });
            cells.Add(new PdfPCell(new Phrase("PUESTO: " + filiationData.v_CurrentOccupation, fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE
            });
            columnWidths = new float[] { 100f };

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

            //***********************************************

            cells = new List <PdfPCell>();

            cellHuellaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellHuellaTrabajador.FixedHeight         = 80F;
            cells.Add(cellHuellaTrabajador);
            cells.Add(new PdfPCell(new Phrase("HUELLA DEL EXAMINADO", fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
            });

            columnWidths = new float[] { 100f };

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

            #endregion

            cells = new List <PdfPCell>();

            // 1 celda vacia
            cells.Add(new PdfPCell(tableFirmaTrabajador));

            // 1 celda vacia
            cells.Add(new PdfPCell(tableHuellaTrabajador));

            // 2 celda
            cell = new PdfPCell(new Phrase("FIRMA Y SELLO MÉDICO", fontColumnValue));
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cells.Add(cell);

            // 3 celda (Imagen)
            cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirma.FixedHeight         = 30F;
            cells.Add(cellFirma);

            columnWidths = new float[] { 25f, 25f, 20f, 30F };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, " ", fontTitleTable);

            document.Add(table);

            #endregion


            document.Close();
            writer.Close();
            writer.Dispose();
        }
    }
        public static void CreateApendiceN2_Evaluacion_Oftalmologica_Yanacocha(PacientList filiationData,
                                                                               List <ServiceComponentList> serviceComponent,
                                                                               organizationDto infoEmpresa,
                                                                               PacientList datosPac,
                                                                               string filePDF, UsuarioGrabo DatosGrabo, List <ServiceComponentList> ExamenesServicio, List <DiagnosticRepositoryList> Diagnosticos)
        {
            Document document = new Document(PageSize.A4, 30f, 30f, 42f, 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 fontColumnValue1 = FontFactory.GetFont("Calibri", 8, 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

            var tamaño_celda = 20f;
            #region TÍTULO

            cells = new List <PdfPCell>();

            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);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("APÉNDICE N° 02: EVALUACIÓN OFTALMOLÓGICA", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f
                },
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);
            document.Add(table);
            #endregion
            #region DATOS GENERALES
            string[] fechaServicio = datosPac.FechaServicio.ToString().Split(' ');
            string   preOcp = "", Ocup = "", postOcup = "";
            if (filiationData.i_EsoTypeId == 1)
            {
                preOcp = "X";
            }
            else if (filiationData.i_EsoTypeId == 2)
            {
                Ocup = "X";
            }
            else if (filiationData.i_EsoTypeId == 3)
            {
                postOcup = "X";
            }

            string empresageneral     = filiationData.empresa_;
            string empresacontrata    = filiationData.contrata;
            string empresasubcontrata = filiationData.subcontrata;

            string empr_Conct = "";
            if (empresageneral != empresasubcontrata)
            {
                empr_Conct = empresacontrata + " / " + empresasubcontrata;
            }
            else
            {
                empr_Conct = empresacontrata;
            }

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("\nApellidos Y Nombres", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + ", " + datosPac.v_FirstName, fontColumnValue))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Edad", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.Edad.ToString() + " Años", fontColumnValue))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Evaluación:", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Pre Ocupacional", fontColumnValue1))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("( " + preOcp + " )", fontColumnValue1))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Ocupacional", fontColumnValue1))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("( " + Ocup + " )", fontColumnValue1))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Post Ocupacional", fontColumnValue1))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("( " + postOcup + " )", fontColumnValue1))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Empresa", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(empr_Conct, fontColumnValue))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
            };

            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
            ServiceComponentList apendice2Yanacocha = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.APENDICE_N_2_EVALUACION_OFTALMOLOGICA_YANACOCHA_ID);

            #region EXAMENES

            var vcscod = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VCSCOD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VCSCOD).v_Value1Name;
            var vcscoi = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VCSCOI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VCSCOI).v_Value1Name;
            var vcccod = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VCCCOD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VCCCOD).v_Value1Name;
            var vcccoi = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VCCCOI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VCCCOI).v_Value1Name;

            var vlscod = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VLSCOD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VLSCOD).v_Value1Name;
            var vlscoi = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VLSCOI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VLSCOI).v_Value1Name;
            var vlccod = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VLCCOD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VLCCOD).v_Value1Name;
            var vlccoi = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VLCCOI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VLCCOI).v_Value1Name;

            var enfermedadesOculares = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_ENFERMEDADES_OCULARES) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_ENFERMEDADES_OCULARES).v_Value1;

            var testIshihara      = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_TEST_ISHIHARA) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_TEST_ISHIHARA).v_Value1Name;
            var reflejosPupilares = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_REFLEJOS_PUPILARES) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_REFLEJOS_PUPILARES).v_Value1Name;

            var maculaOD       = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_MACULA_OD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_MACULA_OD).v_Value1Name;
            var maculaOI       = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_MACULA_OI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_MACULA_OI).v_Value1Name;
            var nervioOpticoOD = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_NERVIO_OPTICO_OD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_NERVIO_OPTICO_OD).v_Value1Name;
            var nervioOpticoOI = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_NERVIO_OPTICO_OI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_NERVIO_OPTICO_OI).v_Value1Name;
            var retinaOD       = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_RETINA_OD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_RETINA_OD).v_Value1Name;
            var retinaOI       = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_RETINA_OI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_RETINA_OI).v_Value1Name;

            var presionIntraOcOD     = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_PRESION_INTRAOCULAR_OD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_PRESION_INTRAOCULAR_OD).v_Value1;
            var presionIntraOcOI     = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_PRESION_INTRAOCULAR_OI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_PRESION_INTRAOCULAR_OI).v_Value1;
            var npresionIntraOcODMed = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_PRESION_INTRAOCULAR_OD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_PRESION_INTRAOCULAR_OD).v_MeasurementUnitName;
            var presionIntraOcOIMed  = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_PRESION_INTRAOCULAR_OI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_PRESION_INTRAOCULAR_OI).v_MeasurementUnitName;

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 15, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("OJOS", fontColumnValueBold))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("SIN CORREGIR", fontColumnValueBold))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("CORREGIDA", fontColumnValueBold))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("ENFERMEDADES OCULARES", fontColumnValueBold))
                {
                    Colspan = 5, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("OJO DERECHO", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("OJO IZQUIERDO", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("OJO DERECHO", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("OJO IZQUIERDO", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("VISIÓN DE CERCA", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vcscod, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vcscoi, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vcccod, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vcccoi, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(enfermedadesOculares, fontColumnValue))
                {
                    Colspan = 5, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("VISIÓN DE LEJOS", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vlscod, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vlscoi, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vlccod, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vlccoi, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("VISIÓN DE COLORES \n (TEST DE ISHIHARA)", fontColumnValueBold))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(testIshihara, fontColumnValue1))
                {
                    Colspan = 12, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase("REFLEJOS PUPILARES", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(reflejosPupilares, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },

                new PdfPCell(new Phrase("FONDO DE OJO \n (FUNDOSCOPIA)", fontColumnValueBold))
                {
                    Colspan = 3, Rowspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("MÁCULA OD", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase(maculaOD, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase("MÁCULA OI", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase(maculaOI, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase("PRESIÓN INTRAOCULAR", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("NERVIO ÓPT OD", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase(nervioOpticoOD, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase("NERVIO ÓPT OI", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase(nervioOpticoOI, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase("OD", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(presionIntraOcOD + " " + npresionIntraOcODMed, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("RETINA OD", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase(retinaOD, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase("RETINA OI", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase(retinaOI, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase("OI", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(presionIntraOcOI + " " + presionIntraOcOIMed, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("NOMBRES Y APELLIDOS DEL MÉDICO", fontColumnValueBold))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("CMP/RNE", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase(DatosGrabo.Nombre, fontColumnValueBold))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(DatosGrabo.CMP, fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
            };

            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, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region Firma

            #region Creando celdas de tipo Imagen y validando nulls
            PdfPCell cellFirmaTrabajador  = null;
            PdfPCell cellHuellaTrabajador = null;
            PdfPCell cellFirma            = null;

            // Firma del trabajador ***************************************************


            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 80, 40));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirmaTrabajador.FixedHeight         = 50F;
            // Huella del trabajador **************************************************

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 30, 45));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellHuellaTrabajador.FixedHeight         = 50F;
            // Firma del doctor Auditor **************************************************

            if (DatosGrabo.Firma != null)
            {
                cellFirma = new PdfPCell(HandlingItextSharp.GetImage(DatosGrabo.Firma, null, null, 120, 50))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                };
            }
            else
            {
                cellFirma = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirma.FixedHeight         = 50F;
            #endregion

            cells = new List <PdfPCell>()
            {
                new PdfPCell(cellFirmaTrabajador)
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
                new PdfPCell(cellHuellaTrabajador)
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("FIRMA Y SELLO DEL MÉDICO", fontColumnValueBold))
                {
                    Rowspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(cellFirma)
                {
                    Rowspan = 3, HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },

                new PdfPCell(new Phrase("FIRMA DEL EXAMINADO", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 12f
                },
                new PdfPCell(new Phrase("HUELLA DEL EXAMINADO", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 12f
                },

                new PdfPCell(new Phrase("CON LA CUAL DECLARA QUE LA INFORMACIÓN DECLARADA ES VERAZ", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
            };
            columnWidths = new float[] { 25f, 25f, 25f, 25f };

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

            document.Add(filiationWorker);

            #endregion

            #region OBSERVACIONES
            //var diagnosticosYanacocha = Diagnosticos.FindAll(p => p.v_ComponentId == Sigesoft.Common.Constants.APENDICE_N_2_EVALUACION_OFTALMOLOGICA_YANACOCHA_ID);
            //cells = new List<PdfPCell>()
            //{
            //    new PdfPCell(new Phrase("Observaciones: ", fontColumnValueBold)) {Colspan = 20,HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders=true, BorderColorLeft=BaseColor.BLACK,  BorderColorRight=BaseColor.BLACK,  BorderColorBottom=BaseColor.WHITE, BorderColorTop=BaseColor.BLACK  },
            //    //new PdfPCell(new Phrase(observaciones, fontColumnValue)) {Colspan = 20,HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20F, UseVariableBorders=true, BorderColorLeft=BaseColor.BLACK,  BorderColorRight=BaseColor.BLACK,  BorderColorBottom=BaseColor.BLACK, BorderColorTop=BaseColor.WHITE  },
            //};

            //if (diagnosticosYanacocha.Count != 0)
            //{
            //    foreach (var item in diagnosticosYanacocha)
            //    {
            //        cells.Add(new PdfPCell(new Phrase(item.v_DiseasesName, fontColumnValue)) { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20F, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE });
            //        //cells.Add(new PdfPCell(new Phrase(item.Recomendations, fontColumnValue)) { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20F, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE });
            //        foreach (var item2 in item.Recomendations)
            //        {
            //            cells.Add(new PdfPCell(new Phrase(item2.v_RecommendationName, fontColumnValue)) { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20F, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, 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, null, fontTitleTable);
            //document.Add(table);
            #endregion
            #region Hallazgos y recomendaciones
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("HALLAZGOS", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },

                new PdfPCell(new Phrase("CIE 10", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },
                new PdfPCell(new Phrase("ESPECIFICACIONES", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },
            };
            columnWidths    = new float[] { 20.6f, 40.6f };
            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);
            document.Add(filiationWorker);
            cells = new List <PdfPCell>();

            var filterDiagnosticRepository = Diagnosticos.FindAll(p => p.v_ComponentId == Sigesoft.Common.Constants.APENDICE_N_2_EVALUACION_OFTALMOLOGICA_YANACOCHA_ID);

            if (filterDiagnosticRepository != null && filterDiagnosticRepository.Count > 0)
            {
                columnWidths = new float[] { 0.7f, 23.6f };
                include      = "i_Item,Valor1";

                foreach (var item in filterDiagnosticRepository)
                {
                    if (item.v_DiseasesId == "N009-DD000000029")
                    {
                        cell = new PdfPCell(new Phrase(""))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }
                    else
                    {
                        cell = new PdfPCell(new Phrase(item.v_DiseasesName, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }

                    ListaComun        oListaComun = null;
                    List <ListaComun> Listacomun  = new List <ListaComun>();

                    if (item.Recomendations.Count > 0)
                    {
                        oListaComun        = new ListaComun();
                        oListaComun.Valor1 = "RECOMENDACIONES";
                        oListaComun.i_Item = "#";
                        Listacomun.Add(oListaComun);
                    }


                    int Contador = 1;
                    foreach (var Reco in item.Recomendations)
                    {
                        oListaComun = new ListaComun();

                        oListaComun.Valor1 = Reco.v_RecommendationName;
                        oListaComun.i_Item = Contador.ToString();
                        Listacomun.Add(oListaComun);
                        Contador++;
                    }

                    if (item.Restrictions.Count > 0)
                    {
                        oListaComun        = new ListaComun();
                        oListaComun.Valor1 = "RESTRICCIONES";
                        oListaComun.i_Item = "#";
                        Listacomun.Add(oListaComun);
                    }
                    int Contador1 = 1;
                    foreach (var Rest in item.Restrictions)
                    {
                        oListaComun        = new ListaComun();
                        oListaComun.Valor1 = Rest.v_RestrictionName;
                        oListaComun.i_Item = Contador1.ToString();
                        Listacomun.Add(oListaComun);
                        Contador1++;
                    }

                    // Crear tabla de recomendaciones para insertarla en la celda que corresponde
                    table = HandlingItextSharp.GenerateTableFromList(Listacomun, columnWidths, include, fontColumnValue);
                    cell  = new PdfPCell(table);

                    cells.Add(cell);
                }

                columnWidths = new float[] { 20.6f, 40.6f };
            }
            else
            {
                cells.Add(new PdfPCell(new Phrase("NO SE HAN REGISTRADO DATOS.", fontColumnValue)));
                columnWidths = new float[] { 100 };
            }

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, null);
            document.Add(table);
            #endregion


            document.Close();
            writer.Close();
            writer.Dispose();
        }
        public static void CreateExamen_Oftalmologico_Simple(PacientList filiationData, ServiceList DataService,
                                                             List <ServiceComponentList> serviceComponent,
                                                             organizationDto infoEmpresa,
                                                             PacientList datosPac,
                                                             string filePDF, UsuarioGrabo DatosGrabo, List <DiagnosticRepositoryList> Diagnosticos)
        {
            Document document = new Document(PageSize.A4, 30f, 30f, 42f, 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", 12, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValue2 = FontFactory.GetFont("Calibri", 8, 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", 6, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValue1 = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 6, 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

            var tamaño_celda = 15f;
            #region TÍTULO

            cells = new List <PdfPCell>();

            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);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);
            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("N° DE FICHA", fontColumnValue2))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_IdService, fontColumnValue2))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("INFORME OFTALMOLÓGICO", fontTitle1))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 75f, 25f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            #region DATOS GENERALES
            string[] fechaServicio = datosPac.FechaServicio.ToString().Split(' ');

            string empresageneral     = filiationData.empresa_;
            string empresacontrata    = filiationData.contrata;
            string empresasubcontrata = filiationData.subcontrata;

            string empr_Conct = "";
            if (empresageneral != empresasubcontrata)
            {
                empr_Conct = empresacontrata + " / " + empresasubcontrata;
            }
            else
            {
                empr_Conct = empresacontrata;
            }

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\nDATOS PERSONALES: ", fontColumnValue2))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("NOMBRES: ", fontColumnValue2))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_FirstName, fontColumnValue1))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("APELLIDOS: ", fontColumnValue2))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName, fontColumnValue1))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("EDAD: ", fontColumnValue2))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.Edad.ToString() + " AÑOS", fontColumnValue1))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("TELEFONO: ", fontColumnValue2))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_TelephoneNumber, fontColumnValue1))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("DOMICILIO: ", fontColumnValue2))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_AdressLocation, fontColumnValue1))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("CONTRATA: ", fontColumnValue2))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(empr_Conct, fontColumnValue1))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("FECHA: ", fontColumnValue2))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(fechaServicio[0], fontColumnValue1))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, 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, null, fontTitleTable);
            document.Add(table);
            #endregion
            ServiceComponentList informeOftalmoSimple = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_ID);

            #region ANTECEDENTES LABORALES
            var antecedentes_laborales = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_DESCRIPCION_LAB) == null ? "NO REFIERE ANTECEDENTES PERSONALES" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_DESCRIPCION_LAB).v_Value1;

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("ANTECEDENTES LABORALES: ", fontColumnValue2))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase(antecedentes_laborales, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20F, 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, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region ANTECEDENTES PATOLÓGICOS
            var antecedentes_patologicos = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_DESCRIPCION_PAT) == null ? "NO REFIERE ANTECEDENTES PATOLÓGICOS" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_DESCRIPCION_PAT).v_Value1;

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("ANTECEDENTES PATOLÓGICOS: ", fontColumnValue2))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

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

                new PdfPCell(new Phrase("", fontColumnValue2))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 2F, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, 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, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region OJOS

            var vcscod = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VCSCOD) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VCSCOD).v_Value1Name;
            var vcscoi = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VCSCOI) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VCSCOI).v_Value1Name;
            var vcccod = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VCCCOD) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VCCCOD).v_Value1Name;
            var vcccoi = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VCCCOI) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VCCCOI).v_Value1Name;

            var vlscod = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VLSCOD) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VLSCOD).v_Value1Name;
            var vlscoi = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VLSCOI) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VLSCOI).v_Value1Name;
            var vlccod = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VLCCOD) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VLCCOD).v_Value1Name;
            var vlccoi = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VLCCOI) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VLCCOI).v_Value1Name;

            var    visioncolores         = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VISION_COLORES) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VISION_COLORES).v_Value1Name;
            var    enfermedadesOculares  = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_ENFERMEDADES_OCULARES) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_ENFERMEDADES_OCULARES).v_Value1;
            var    reflejosPupilares     = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_REFLEJOS_PUPILARES) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_REFLEJOS_PUPILARES).v_Value1Name;
            var    vision_estereoscopica = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_TEST_VISION_ESTEREOSCOPICA) == null ? "NO APLICA" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_TEST_VISION_ESTEREOSCOPICA).v_Value1;
            string stereocopica          = "";
            if (vision_estereoscopica == "-1")
            {
                stereocopica = "NO APLICA";
            }
            else if (vision_estereoscopica == "1")
            {
                stereocopica = "ANORMAL";
            }
            else if (vision_estereoscopica == "2")
            {
                stereocopica = "NORMAL";
            }


            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("OJOS", fontColumnValueBold))
                {
                    Colspan = 4, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("SIN CORREGIR", fontColumnValueBold))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("CORREGIDA", fontColumnValueBold))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("OJO DERECHO", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("OJO IZQUIERDO", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("OJO DERECHO", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("OJO IZQUIERDO", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("VISIÓN DE CERCA", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vcscod, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vcscoi, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vcccod, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vcccoi, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("VISIÓN DE LEJOS", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vlscod, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vlscoi, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vlccod, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vlccoi, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("VISIÓN DE COLORES", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(visioncolores, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },

                new PdfPCell(new Phrase("ENFERMEDADES OCULARES", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(enfermedadesOculares == null?"- - -":enfermedadesOculares == ""?"- - -":enfermedadesOculares, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },

                new PdfPCell(new Phrase("REFLEJOS PUPILARES", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(reflejosPupilares, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },

                new PdfPCell(new Phrase("TEST DE VISIÓN ESTEREOSCÓPICA", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(stereocopica, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 2F, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, 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 };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region  APTITUD OFTALMOLOGO
            //var aptitud = informe_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_GOLDFIELDS_APTITUD_PSICO) == null ? "" : informe_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_GOLDFIELDS_APTITUD_PSICO).v_Value1;
            //var conclusion_desc = informe_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_GOLDFIELDS_APTITUD_PSICO_DESC) == null ? "" : informe_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_GOLDFIELDS_APTITUD_PSICO_DESC).v_Value1;
            var    aptoSi = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_APTITUD_SI) == null ? "" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_APTITUD_SI).v_Value1;
            var    aptoNo = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_APTITUD_NO) == null ? "" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_APTITUD_NO).v_Value1;
            string nombreDoc = "", cmp = "";
            if (DataService != null)
            {
                nombreDoc = DataService.NombreDoctor;
                cmp       = DataService.CMP;
            }
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("APTO PARA TRABAJAR", fontColumnValueBold))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("NOMBRES Y APELLIDOS DEL MÉDICO", fontColumnValueBold))
                {
                    Colspan = 9, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("CMP/RNE", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("SI", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(aptoSi == "1"?"X":aptoSi == "0"?"":aptoSi, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("NO", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(aptoNo == "1"?"X":aptoNo == "0"?"":aptoNo, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase(nombreDoc, fontColumnValueBold))
                {
                    Colspan = 9, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(cmp, fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
            };

            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, null, fontTitleTable);
            document.Add(table);
            #endregion

            //var psico = serviceComponent.Find(p => p.i_CategoryId == (int)Sigesoft.Common.Consultorio.Psicología);

            #region Firma

            #region Creando celdas de tipo Imagen y validando nulls
            PdfPCell cellFirmaTrabajador  = null;
            PdfPCell cellHuellaTrabajador = null;
            PdfPCell cellFirma            = null;

            // Firma del trabajador ***************************************************


            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 80, 40));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirmaTrabajador.FixedHeight         = 50F;
            // Huella del trabajador **************************************************

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 30, 45));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellHuellaTrabajador.FixedHeight         = 50F;
            // Firma del doctor Auditor **************************************************
            if (DatosGrabo != null)
            {
                if (DatosGrabo.Firma != null)
                {
                    cellFirma = new PdfPCell(HandlingItextSharp.GetImage(DatosGrabo.Firma, null, null, 120, 50))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_CENTER
                    }
                }
                ;
                else
                {
                    cellFirma = new PdfPCell(new Phrase(" ", fontColumnValue));
                }

                cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
                cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cellFirma.FixedHeight         = 50F;
            }

            #endregion

            cells = new List <PdfPCell>()
            {
                new PdfPCell(cellFirmaTrabajador)
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
                new PdfPCell(cellHuellaTrabajador)
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("FIRMA Y SELLO DEL MÉDICO", fontColumnValueBold))
                {
                    Rowspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(cellFirma)
                {
                    Rowspan = 3, HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },

                new PdfPCell(new Phrase("FIRMA DEL EXAMINADO", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 12f
                },
                new PdfPCell(new Phrase("HUELLA DEL EXAMINADO", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 12f
                },

                new PdfPCell(new Phrase("CON LA CUAL DECLARA QUE LA INFORMACIÓN DECLARADA ES VERAZ", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
            };
            columnWidths = new float[] { 25f, 25f, 25f, 25f };

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

            document.Add(filiationWorker);

            #endregion

            #region EXAMENES AUXILIARES COMPLEMENTARIOS
            //var examenesAuxiliares = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_EXAMENES_AUXILIARES) == null ? "NO REFIERE EXAMENES AUXILIARES" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_EXAMENES_AUXILIARES).v_Value1;

            //cells = new List<PdfPCell>()
            //{

            //    new PdfPCell(new Phrase("EXAMENES AUXILIARES COMPLEMENTARIOS: ", fontColumnValue2)) {Colspan = 20,HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders=true, BorderColorLeft=BaseColor.BLACK,  BorderColorRight=BaseColor.BLACK,  BorderColorBottom=BaseColor.WHITE, BorderColorTop=BaseColor.BLACK  },

            //    new PdfPCell(new Phrase(examenesAuxiliares, fontColumnValue)) {Colspan = 20,HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20F, UseVariableBorders=true, BorderColorLeft=BaseColor.BLACK,  BorderColorRight=BaseColor.BLACK,  BorderColorBottom=BaseColor.BLACK, BorderColorTop=BaseColor.WHITE  },

            //    //new PdfPCell(new Phrase("", fontTitle3)) {Colspan = 20,HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 2F, 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 };
            //table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            //document.Add(table);
            #endregion

            #region Hallazgos y recomendaciones
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("HALLAZGOS Y EXAMENES AUXILIARES COMPLEMENTARIOS ", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },

                new PdfPCell(new Phrase("CIE 10", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },
                new PdfPCell(new Phrase("ESPECIFICACIONES", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },
            };
            columnWidths    = new float[] { 20.6f, 40.6f };
            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);
            document.Add(filiationWorker);
            cells = new List <PdfPCell>();

            var filterDiagnosticRepository = Diagnosticos.FindAll(p => p.v_ComponentId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_ID);

            if (filterDiagnosticRepository != null && filterDiagnosticRepository.Count > 0)
            {
                columnWidths = new float[] { 0.7f, 23.6f };
                include      = "i_Item,Valor1";

                foreach (var item in filterDiagnosticRepository)
                {
                    if (item.v_DiseasesId == "N009-DD000000029")
                    {
                        cell = new PdfPCell(new Phrase(""))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }
                    else
                    {
                        cell = new PdfPCell(new Phrase(item.v_DiseasesName, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }

                    ListaComun        oListaComun = null;
                    List <ListaComun> Listacomun  = new List <ListaComun>();

                    if (item.Recomendations.Count > 0)
                    {
                        oListaComun        = new ListaComun();
                        oListaComun.Valor1 = "RECOMENDACIONES";
                        oListaComun.i_Item = "#";
                        Listacomun.Add(oListaComun);
                    }


                    int Contador = 1;
                    foreach (var Reco in item.Recomendations)
                    {
                        oListaComun = new ListaComun();

                        oListaComun.Valor1 = Reco.v_RecommendationName;
                        oListaComun.i_Item = Contador.ToString();
                        Listacomun.Add(oListaComun);
                        Contador++;
                    }

                    if (item.Restrictions.Count > 0)
                    {
                        oListaComun        = new ListaComun();
                        oListaComun.Valor1 = "RESTRICCIONES";
                        oListaComun.i_Item = "#";
                        Listacomun.Add(oListaComun);
                    }
                    int Contador1 = 1;
                    foreach (var Rest in item.Restrictions)
                    {
                        oListaComun        = new ListaComun();
                        oListaComun.Valor1 = Rest.v_RestrictionName;
                        oListaComun.i_Item = Contador1.ToString();
                        Listacomun.Add(oListaComun);
                        Contador1++;
                    }

                    // Crear tabla de recomendaciones para insertarla en la celda que corresponde
                    table = HandlingItextSharp.GenerateTableFromList(Listacomun, columnWidths, include, fontColumnValue);
                    cell  = new PdfPCell(table);

                    cells.Add(cell);
                }

                columnWidths = new float[] { 20.6f, 40.6f };
            }
            else
            {
                cells.Add(new PdfPCell(new Phrase("NO SE HAN REGISTRADO DATOS.", fontColumnValue)));
                columnWidths = new float[] { 100 };
            }

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, null);
            document.Add(table);
            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
        }
Пример #6
0
        public static void CreateCertificadoMedicoOcupacional_Cosapi(ServiceList DataService,
                                                                     PacientList filiationData,
                                                                     List <DiagnosticRepositoryList> Diagnosticos,
                                                                     List <ServiceComponentList> serviceComponent,
                                                                     organizationDto infoEmpresa,
                                                                     PacientList datosPac,
                                                                     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.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

            var tamaño_celda = 14f;
            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresa.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresa.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 785);
                document.Add(imagenEmpresa);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("CERTIFICADO DE APTITUD MÉDICO OCUPACIONAL", fontTitle1))
                {
                    Colspan = 2, BackgroundColor = BaseColor.GRAY, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f
                },
            };
            columnWidths = new float[] { 80f, 20f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            #region DATOS GENERALES
            string sexM = " ", sexF = " ";
            if (datosPac.i_SexTypeId == 1)
            {
                sexM = "X";
            }
            else if (datosPac.i_SexTypeId == 2)
            {
                sexF = "X";
            }

            string PreOcupacional = "", Periodica = "", Retiro = "", Otros = "";
            if (DataService != null)
            {
                if (DataService.i_EsoTypeId == (int)Sigesoft.Common.TypeESO.PreOcupacional)
                {
                    PreOcupacional = "X";
                }
                else if (DataService.i_EsoTypeId == (int)Sigesoft.Common.TypeESO.PeriodicoAnual)
                {
                    Periodica = "X";
                }
                else if (DataService.i_EsoTypeId == (int)Sigesoft.Common.TypeESO.Retiro)
                {
                    Retiro = "X";
                }
                else
                {
                    Otros = "X";
                }
            }
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    BackgroundColor = BaseColor.GRAY, Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f
                },
                new PdfPCell(new Phrase("Código", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f
                },
                new PdfPCell(new Phrase(datosPac.v_IdService, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f
                },

                new PdfPCell(new Phrase("Certifica que el Sr.(a)", fontColumnValue))
                {
                    Colspan = 15, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Grupo Sanguineo y Factor", fontColumnValue))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_BloodGroupName, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_BloodFactorName, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Nombres y Apellidos", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Documento de identidad (DNI ó C.E):", fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_DocNumber, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Edad", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.Edad.ToString(), fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Género:", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("M", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(sexM, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("F", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(sexF, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Tipo de examen", fontColumnValue))
                {
                    Colspan = 4, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Preocupacional", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(PreOcupacional, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Periódico", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(Periodica, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Retiro", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(Retiro, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Otro(Especifique)", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(Otros, fontColumnValue))
                {
                    Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Empresa", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(filiationData.v_FullWorkingOrganizationName, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Proyecto/Sede - Cliente", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(filiationData.v_NombreProtocolo, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Puesto de trabajo", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_CurrentOccupation, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("N° de Historia Clínica", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_DocNumber, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase(null, fontColumnValue))
                {
                    BackgroundColor = BaseColor.GRAY, Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 2
                },
            };

            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, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region Hallazgos y recomendaciones
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("Recomendaciones", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },
            };
            columnWidths    = new float[] { 20.6f, 40.6f };
            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);
            document.Add(filiationWorker);
            cells = new List <PdfPCell>();

            var filterDiagnosticRepository = Diagnosticos.FindAll(p => p.i_FinalQualificationId != (int)Sigesoft.Common.FinalQualification.Descartado);

            if (filterDiagnosticRepository != null && filterDiagnosticRepository.Count > 0)
            {
                columnWidths = new float[] { 100f };
                include      = "Valor1";

                foreach (var item in filterDiagnosticRepository)
                {
                    ListaComun        oListaComun = null;
                    List <ListaComun> Listacomun  = new List <ListaComun>();

                    foreach (var Reco in item.Recomendations)
                    {
                        oListaComun        = new ListaComun();
                        oListaComun.Valor1 = Reco.v_RecommendationName;
                        Listacomun.Add(oListaComun);
                    }

                    table = HandlingItextSharp.GenerateTableFromList(Listacomun, columnWidths, include, fontColumnValue);
                    cell  = new PdfPCell(table);

                    cells.Add(cell);
                }
                columnWidths = new float[] { 100f };
            }
            else
            {
                cells.Add(new PdfPCell(new Phrase("NO SE HAN REGISTRADO DATOS.", fontColumnValue)));
                columnWidths = new float[] { 100f };
            }
            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, null);
            document.Add(table);
            /////

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("Restricciones", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },
            };
            columnWidths    = new float[] { 20.6f, 40.6f };
            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);
            document.Add(filiationWorker);
            cells = new List <PdfPCell>();

            var filterDiagnosticRepository_1 = Diagnosticos.FindAll(p => p.i_FinalQualificationId != (int)Sigesoft.Common.FinalQualification.Descartado);

            if (filterDiagnosticRepository_1 != null && filterDiagnosticRepository_1.Count > 0)
            {
                columnWidths = new float[] { 100f };
                include      = "Valor1";

                //var desc = Diagnosticos.Find(p => p.Restrictions != (int)Sigesoft.Common.FinalQualification.Descartado);
                foreach (var item_1 in filterDiagnosticRepository_1)
                {
                    ListaComun        oListaComun = null;
                    List <ListaComun> Listacomun  = new List <ListaComun>();

                    foreach (var Rest_1 in item_1.Restrictions)
                    {
                        oListaComun        = new ListaComun();
                        oListaComun.Valor1 = Rest_1.v_RestrictionName;
                        Listacomun.Add(oListaComun);
                    }
                    table = HandlingItextSharp.GenerateTableFromList(Listacomun, columnWidths, include, fontColumnValue);
                    cell  = new PdfPCell(table);
                    cells.Add(cell);
                }
                columnWidths = new float[] { 100f };
            }
            else
            {
                cells.Add(new PdfPCell(new Phrase("NO SE HAN REGISTRADO DATOS.", fontColumnValue)));
                columnWidths = new float[] { 100 };
            }

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, null);
            document.Add(table);
            #endregion

            #region RESULTADO DE APROBACION / FECHAS
            string Apto = "", NoApto = "", AptoConRestricciones = "", AptoObs = "";

            if (DataService.i_AptitudeStatusId == (int)Sigesoft.Common.AptitudeStatus.Apto)
            {
                Apto = "X";
            }
            else if (DataService.i_AptitudeStatusId == (int)Sigesoft.Common.AptitudeStatus.NoApto)
            {
                NoApto = "X";
            }
            else if (DataService.i_AptitudeStatusId == (int)Sigesoft.Common.AptitudeStatus.AptRestriccion)
            {
                AptoConRestricciones = "X";
            }
            else if (DataService.i_AptitudeStatusId == (int)Sigesoft.Common.AptitudeStatus.AptoObs)
            {
                AptoObs = "X";
            }

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("Resultado para Trabajar", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = PdfPCell.ALIGN_LEFT, BackgroundColor = BaseColor.GRAY, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("APTO", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = PdfPCell.ALIGN_LEFT, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(Apto, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("APTO CON RESTRICCIONES", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = PdfPCell.ALIGN_LEFT, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(AptoConRestricciones, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("NO APTO", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = PdfPCell.ALIGN_LEFT, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(NoApto, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
            };
            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, "", fontTitleTable);

            document.Add(filiationWorker);
            #endregion
            #region APTITUDES ESPECÍFICAS

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("APTITUDES ESPECÍFICAS:", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },
            };
            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, fontTitleTableNegro, null);
            document.Add(filiationWorker);

            ServiceComponentList geografico  = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.ALTURA_GEOGRAFICA_ID);
            if (geografico != null)
            {
                var    alt_geograf = geografico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.ALTURA_GEOGRAFICA_APTO_ID) == null ? "" : geografico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.ALTURA_GEOGRAFICA_APTO_ID).v_Value1;
                string alt_geograf_1 = "", alt_geograf_2 = "", alt_geograf_3 = "", alt_geograf_4 = "";
                if (alt_geograf == "1")
                {
                    alt_geograf_1 = "X";
                }
                else if (alt_geograf == "2")
                {
                    alt_geograf_2 = "X";
                }
                else if (alt_geograf == "3")
                {
                    alt_geograf_3 = "X";
                }
                else if (alt_geograf == "4")
                {
                    alt_geograf_4 = "X";
                }


                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("Trabajador en altura geográfica mayor a 2500 m.s.n.m.", fontColumnValue))
                    {
                        Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("APTO", fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase(alt_geograf_1, fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("NO APTO", fontColumnValue))
                    {
                        Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase(alt_geograf_2, fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("APTO CON RESTRIC.", fontColumnValue))
                    {
                        Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase(alt_geograf_3, fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("OBSERVADO", fontColumnValue))
                    {
                        Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase(alt_geograf_4, fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                };
                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, fontTitleTableNegro, null);
                document.Add(filiationWorker);
            }
            else
            {
                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("Trabajador en altura geográfica mayor a 2500 m.s.n.m.", fontColumnValue))
                    {
                        Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("NO APLICA", fontColumnValue))
                    {
                        Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                };
                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, fontTitleTableNegro, null);
                document.Add(filiationWorker);
            }

            ServiceComponentList estructural = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.ALTURA_ESTRUCTURAL_ID);
            if (estructural != null)
            {
                var    alt_estruc = estructural.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.ALTURA_ESTRUCTURAL_APTO_ID) == null ? "" : estructural.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.ALTURA_ESTRUCTURAL_APTO_ID).v_Value1;
                string alt_estruc_1 = "", alt_estruc_2 = "", alt_estruc_3 = "", alt_estruc_4 = "";
                if (alt_estruc == "1")
                {
                    alt_estruc_1 = "X";
                }
                else if (alt_estruc == "2")
                {
                    alt_estruc_2 = "X";
                }
                else if (alt_estruc == "3")
                {
                    alt_estruc_3 = "X";
                }
                else if (alt_estruc == "4")
                {
                    alt_estruc_4 = "X";
                }
                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("Trabajos en altura estructural mayor a 1.8m:", fontColumnValue))
                    {
                        Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("APTO", fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase(alt_estruc_1, fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("NO APTO", fontColumnValue))
                    {
                        Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase(alt_estruc_2, fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("APTO CON RESTRIC.", fontColumnValue))
                    {
                        Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase(alt_estruc_3, fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("OBSERVADO", fontColumnValue))
                    {
                        Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase(alt_estruc_4, fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                };
                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, fontTitleTableNegro, null);
                document.Add(filiationWorker);
            }
            else
            {
                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("Trabajos en altura estructural mayor a 1.8m:", fontColumnValue))
                    {
                        Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("NO APLICA", fontColumnValue))
                    {
                        Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                };
                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, fontTitleTableNegro, null);
                document.Add(filiationWorker);
            }
            #endregion
            #region FECHA  NOMBRE DE MEDICO
            string[] fechaServicio           = datosPac.FechaServicio.ToString().Split(' ');
            string[] fechacaducidad          = datosPac.FechaCaducidad.ToString().Split(' ');
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("FECHA DE EXAMEN", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = PdfPCell.ALIGN_LEFT, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(fechaServicio[0], fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("FECHA DE CADUCIDAD", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = PdfPCell.ALIGN_LEFT, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(fechacaducidad[0], fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("MÉDICO: ", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = PdfPCell.ALIGN_LEFT, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(DataService.NombreDoctor, fontColumnValue))
                {
                    Colspan = 9, HorizontalAlignment = PdfPCell.ALIGN_CENTER, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Número de CMP:", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = PdfPCell.ALIGN_LEFT, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(DataService.CMP, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = PdfPCell.ALIGN_CENTER, MinimumHeight = tamaño_celda
                },
            };
            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, "", fontTitleTable);

            document.Add(filiationWorker);
            #endregion
            #region Firma

            #region Creando celdas de tipo Imagen y validando nulls

            // Firma del trabajador ***************************************************
            PdfPCell cellFirmaTrabajador = null;
            //DirectoryInfo rutaFirma = null;
            //rutaFirma = new DirectoryInfo(WebConfigurationManager.AppSettings["FirmaHuella"].ToString());
            //iTextSharp.text.Image Firmajpg = iTextSharp.text.Image.GetInstance(rutaFirma +DataService.v_DocNumber + "_Firma.jpg");


            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 70, 30));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }
            //cellFirmaTrabajador = new PdfPCell(Firmajpg);

            // Huella del trabajador **************************************************
            PdfPCell cellHuellaTrabajador = null;

            //DirectoryInfo rutaHuella = null;
            //rutaHuella = new DirectoryInfo(WebConfigurationManager.AppSettings["FirmaHuella"].ToString());
            //iTextSharp.text.Image Huellajpg = iTextSharp.text.Image.GetInstance(rutaHuella + DataService.v_DocNumber + "_Huella.jpg");

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 30, 30));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }
            //cellHuellaTrabajador = new PdfPCell(Huellajpg);

            // Firma del doctor Auditor **************************************************

            PdfPCell cellFirma = null;

            if (DataService.FirmaMedicoMedicina != null)
            {
                cellFirma = new PdfPCell(HandlingItextSharp.GetImage(DataService.FirmaMedicoMedicina, null, null, 120, 50))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                }
            }
            ;
            else
            {
                cellFirma = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            #endregion

            #region Crear tablas en duro (para la Firma y huella del trabajador)

            cells = new List <PdfPCell>();

            cellFirmaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirmaTrabajador.Border      = PdfPCell.NO_BORDER;
            cellFirmaTrabajador.FixedHeight = 40F;
            cells.Add(cellFirmaTrabajador);
            cells.Add(new PdfPCell(new Phrase("FIRMA DEL EXAMINADO", fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
            });

            columnWidths = new float[] { 100f };

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

            //***********************************************

            cells = new List <PdfPCell>();

            cellHuellaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirmaTrabajador.Border       = PdfPCell.NO_BORDER;
            cellHuellaTrabajador.FixedHeight = 40F;
            cells.Add(cellHuellaTrabajador);
            cells.Add(new PdfPCell(new Phrase("HUELLA DEL EXAMINADO", fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
            });

            columnWidths = new float[] { 100f };

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

            #endregion

            cells = new List <PdfPCell>();

            // 1 celda vacia
            cells.Add(new PdfPCell(tableFirmaTrabajador));

            // 1 celda vacia
            cells.Add(new PdfPCell(tableHuellaTrabajador));

            // 2 celda
            cell = new PdfPCell(new Phrase("FIRMA Y SELLO MÉDICO", fontColumnValue))
            {
                Rowspan = 2
            };
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cells.Add(cell);

            // 3 celda (Imagen)
            cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirma.FixedHeight         = 40F;
            cells.Add(cellFirma);

            cells.Add(new PdfPCell(new Phrase("CON LA CUAL DECLARA QUE LA INFORMACIÓN DECLARADA ES VERAZ", fontColumnValue))
            {
                Colspan = 2, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE
            });
            cells.Add(new PdfPCell(new Phrase("", fontColumnValue))
            {
                Colspan = 2, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
            });

            columnWidths = new float[] { 35f, 35f, 30f, 40F };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);

            document.Add(table);

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