예제 #1
0
        public virtual void SetAndGetMarginsTest()
        {
            float expectedMarginTop    = 92;
            float expectedMarginRight  = 90;
            float expectedMarginBottom = 86;
            float expectedMarginLeft   = 88;
            Style style = new Style();

            NUnit.Framework.Assert.IsNull(style.GetMarginTop());
            NUnit.Framework.Assert.IsNull(style.GetMarginRight());
            NUnit.Framework.Assert.IsNull(style.GetMarginBottom());
            NUnit.Framework.Assert.IsNull(style.GetMarginLeft());
            style.SetMargins(expectedMarginTop, expectedMarginRight, expectedMarginBottom, expectedMarginLeft);
            NUnit.Framework.Assert.AreEqual(UnitValue.CreatePointValue(expectedMarginTop), style.GetMarginTop());
            NUnit.Framework.Assert.AreEqual(UnitValue.CreatePointValue(expectedMarginRight), style.GetMarginRight());
            NUnit.Framework.Assert.AreEqual(UnitValue.CreatePointValue(expectedMarginBottom), style.GetMarginBottom());
            NUnit.Framework.Assert.AreEqual(UnitValue.CreatePointValue(expectedMarginLeft), style.GetMarginLeft());
        }
예제 #2
0
        public virtual void SetMarginsViaStyleTest()
        {
            float expectedMarginTop    = 92;
            float expectedMarginRight  = 90;
            float expectedMarginBottom = 86;
            float expectedMarginLeft   = 88;
            Style style = new Style();

            style.SetMargins(expectedMarginTop, expectedMarginRight, expectedMarginBottom, expectedMarginLeft);
            Paragraph p = new Paragraph("Hello, iText!");

            p.AddStyle(style);
            NUnit.Framework.Assert.AreEqual(UnitValue.CreatePointValue(expectedMarginTop), p.GetProperty <UnitValue>(Property
                                                                                                                     .MARGIN_TOP));
            NUnit.Framework.Assert.AreEqual(UnitValue.CreatePointValue(expectedMarginRight), p.GetProperty <UnitValue>(
                                                Property.MARGIN_RIGHT));
            NUnit.Framework.Assert.AreEqual(UnitValue.CreatePointValue(expectedMarginBottom), p.GetProperty <UnitValue>
                                                (Property.MARGIN_BOTTOM));
            NUnit.Framework.Assert.AreEqual(UnitValue.CreatePointValue(expectedMarginLeft), p.GetProperty <UnitValue>(Property
                                                                                                                      .MARGIN_LEFT));
        }
예제 #3
0
        public static async Task CrearGraficosIndividualesEnPdf_7(Document doc, ListCollectionView lista, DateTime fecha)
        {
            await Task.Run(() => {
                int indice = 1;
                double num = 1;
                foreach (object obj in lista)
                {
                    double valor = num / lista.Count * 100;
                    App.Global.ValorBarraProgreso = valor;
                    num++;
                    Grafico g = obj as Grafico;
                    if (g == null)
                    {
                        continue;
                    }
                    if (indice > 1)
                    {
                        doc.Add(new AreaBreak(AreaBreakType.NEXT_PAGE));
                    }
                    // Creamos la tabla de título
                    //Table tablaTitulo = PdfTools.GetTablaTitulo($"{fecha:dd - MMMM - yyyy}".ToUpper(), App.Global.CentroActual.ToString().ToUpper());
                    string textoTitulo = $"{fecha:dd - MMMM - yyyy}\n{App.Global.CentroActual}".ToUpper();
                    iText.Layout.Style estiloTitulo = new iText.Layout.Style();
                    estiloTitulo.SetFontSize(12).SetBold();
                    estiloTitulo.SetMargins(0, 0, 6, 0);
                    estiloTitulo.SetPadding(0);
                    estiloTitulo.SetWidth(UnitValue.CreatePercentValue(100));
                    estiloTitulo.SetBorder(iText.Layout.Borders.Border.NO_BORDER);
                    Table tablaTitulo = InformesServicio.GetTablaEncabezadoSindicato(textoTitulo, estiloTitulo);
                    // TODO: Creamos la tabla de informacion
                    string textoGrafico    = "Gráfico: " + (string)cnvNumGrafico.Convert(g.Numero, null, null, null) + "   Turno: " + g.Turno.ToString("0");
                    string textoValoracion = "Valoración: " + (string)cnvHora.Convert(g.Valoracion, null, VerValores.NoCeros, null);
                    Table tablaInformacion = PdfTools.GetTablaTitulo(textoGrafico, textoValoracion);
                    tablaInformacion.SetWidth(UnitValue.CreatePercentValue(100));
                    tablaInformacion.SetFontSize(9).SetBold();
                    // Creamos la tabla de valoraciones
                    Table tablaValoraciones = GetGraficoIndividual(g);
                    // TODO: Creamos la tabla de valores
                    string textoValores = "";
                    if (g.Desayuno > 0)
                    {
                        textoValores += String.Format("Desayuno: {0:0.00}  ", g.Desayuno);
                    }
                    if (g.Comida > 0)
                    {
                        textoValores += String.Format("Comida: {0:0.00}  ", g.Comida);
                    }
                    if (g.Cena > 0)
                    {
                        textoValores += String.Format("Cena: {0:0.00}  ", g.Cena);
                    }
                    if (g.PlusCena > 0)
                    {
                        textoValores += String.Format("Plus Cena: {0:0.00}  ", g.PlusCena);
                    }
                    if (g.PlusLimpieza)
                    {
                        textoValores += "Limp.  ";
                    }
                    if (g.PlusPaqueteria)
                    {
                        textoValores += "Paqu.  ";
                    }
                    string textoHoras = $"Trab: {(string)cnvHora.Convert(g.Trabajadas, null, null, null)}  " +
                                        $"Acum: {(string)cnvHora.Convert(g.Acumuladas, null, null, null)}  " +
                                        $"Noct: {(string)cnvHora.Convert(g.Nocturnas, null, null, null)}";
                    Table tablaValores = PdfTools.GetTablaTitulo(textoValores, textoHoras);
                    tablaValores.SetWidth(UnitValue.CreatePercentValue(100));
                    tablaValores.SetFontSize(9).SetBold();

                    // Añadimos las tablas al documento
                    doc.Add(tablaTitulo);
                    doc.Add(tablaInformacion);
                    doc.Add(tablaValoraciones);
                    doc.Add(tablaValores);
                    indice++;
                }
            });
        }