Ejemplo n.º 1
0
        public void CreateInitialSection(string name, string id)
        {
            CreateSectionLabel("Datos de Usuario");

            text = new Paragraph("Nombre Completo");
            text.AddStyle(boldTextStyle)
            .SetFontSize(12)
            .SetMarginLeft(25);
            document.Add(text);

            text = new Paragraph(name);
            text.AddStyle(textBoxStyle)
            .SetMarginLeft(25)
            .SetMarginTop(-2)
            .SetWidth(200);
            document.Add(text);

            text = new Paragraph("Número de Identificación");
            text.AddStyle(boldTextStyle)
            .SetFontSize(12)
            .SetMarginTop(-1)
            .SetMarginLeft(25);
            document.Add(text);

            text = new Paragraph(id);
            text.AddStyle(textBoxStyle)
            .SetMarginLeft(25)
            .SetMarginTop(-2)
            .SetWidth(250);
            document.Add(text);
        }
Ejemplo n.º 2
0
        public virtual void SetKeepTogetherFalseViaStyleTest()
        {
            Style falseStyle = new Style();

            falseStyle.SetKeepTogether(false);
            Paragraph p = new Paragraph();

            p.AddStyle(falseStyle);
            NUnit.Framework.Assert.AreEqual(false, p.IsKeepTogether());
        }
Ejemplo n.º 3
0
        public virtual void KeepTogetherFalseTest()
        {
            Style falseStyle = new Style();

            falseStyle.SetKeepTogether(false);
            Paragraph p = new Paragraph();

            p.AddStyle(falseStyle);
            NUnit.Framework.Assert.AreEqual(false, p.GetProperty <bool?>(Property.KEEP_TOGETHER));
        }
Ejemplo n.º 4
0
        public virtual void SetKeepTogetherTrueViaStyleTest()
        {
            Style trueStyle = new Style();

            trueStyle.SetKeepTogether(true);
            Paragraph p1 = new Paragraph();

            p1.AddStyle(trueStyle);
            NUnit.Framework.Assert.AreEqual(true, p1.IsKeepTogether());
        }
        private void SetFooter(PdfFormField toSet, iText.Kernel.Pdf.PdfDocument pdfDoc, int pagina, List <PdfConfiguratie> footerTeksten)
        {
            toSet.SetValue("");

            var afmetingen = toSet.GetWidgets().SelectMany(f => f.GetRectangle()).ToArray();
            var x          = (int)Convert.ToDouble(afmetingen[0].ToString().Replace(".", ","));
            var y          = (int)Convert.ToDouble(afmetingen[1].ToString().Replace(".", ","));
            var wWidth     = (int)Convert.ToDouble(afmetingen[2].ToString().Replace(".", ","));
            var wHeigth    = (int)Convert.ToDouble(afmetingen[3].ToString().Replace(".", ","));

            Document d           = new Document(pdfDoc);
            var      footerTekst = footerTeksten.FirstOrDefault();

            if (footerTekst == null)
            {
                return;
            }
            var paragraaf = new Paragraph(footerTekst.Value);

            paragraaf.SetFontSize(14);
            var styleBold = new Style();

            styleBold.SetBold();
            paragraaf.AddStyle(styleBold);
            var bottom = y + wHeigth - GetParagraafHeight(paragraaf, d, wWidth) * 2;

            paragraaf.SetFixedPosition(pagina, x, bottom, wWidth);
            d.Add(paragraaf);

            footerTekst = footerTeksten.Skip(1).FirstOrDefault();
            if (footerTekst == null)
            {
                return;
            }
            var paragraaf2 = new Paragraph(footerTekst.Value);

            paragraaf2.SetFontSize(12);
            bottom -= GetParagraafHeight(paragraaf2, d, wWidth);
            paragraaf2.SetFixedPosition(pagina, x, bottom, wWidth);
            d.Add(paragraaf2);

            footerTekst = footerTeksten.Skip(2).FirstOrDefault();
            if (footerTekst == null)
            {
                return;
            }
            var paragraaf3 = new Paragraph(footerTekst.Value);

            paragraaf3.SetFontSize(14);
            bottom -= GetParagraafHeight(paragraaf3, d, wWidth);
            paragraaf3.SetFixedPosition(pagina, x, bottom, wWidth);
            d.Add(paragraaf3);
        }
Ejemplo n.º 6
0
        public virtual void SetMinWidthViaStyleTest()
        {
            float expectedMinWidth = 20;
            Style style            = new Style();

            style.SetMinWidth(expectedMinWidth);
            Paragraph p = new Paragraph();

            p.AddStyle(style);
            NUnit.Framework.Assert.AreEqual(UnitValue.CreatePointValue(expectedMinWidth), p.GetProperty <UnitValue>(Property
                                                                                                                    .MIN_WIDTH));
        }
Ejemplo n.º 7
0
        public virtual void SetMinHeightViaStyleTest()
        {
            float expectedMinHeight = 20;
            Style style             = new Style();

            style.SetMinHeight(expectedMinHeight);
            Paragraph p = new Paragraph();

            p.AddStyle(style);
            NUnit.Framework.Assert.AreEqual(UnitValue.CreatePointValue(expectedMinHeight), p.GetProperty <UnitValue>(Property
                                                                                                                     .MIN_HEIGHT));
        }
Ejemplo n.º 8
0
        public virtual void SetRotationAngleViaStyleTest()
        {
            float expectedRotationAngle = 20f;
            Style style = new Style();

            style.SetRotationAngle(expectedRotationAngle);
            Paragraph p = new Paragraph();

            p.AddStyle(style);
            NUnit.Framework.Assert.AreEqual(expectedRotationAngle, (float)p.GetProperty <float?>(Property.ROTATION_ANGLE
                                                                                                 ), EPS);
        }
Ejemplo n.º 9
0
        public virtual void SetSpacingRatioViaStyleTest()
        {
            float expectedSpacingRatio = 0.5f;
            Style style = new Style();

            style.SetSpacingRatio(expectedSpacingRatio);
            Paragraph p = new Paragraph();

            p.AddStyle(style);
            NUnit.Framework.Assert.AreEqual(expectedSpacingRatio, (float)p.GetProperty <float?>(Property.SPACING_RATIO)
                                            , EPS);
        }
Ejemplo n.º 10
0
        public virtual void SetVerticalAlignmentViaStyleTest()
        {
            VerticalAlignment?expectedAlignment = VerticalAlignment.MIDDLE;
            Style             style             = new Style();

            style.SetVerticalAlignment(expectedAlignment);
            Paragraph p = new Paragraph();

            p.AddStyle(style);
            NUnit.Framework.Assert.AreEqual(expectedAlignment, p.GetProperty <VerticalAlignment?>(Property.VERTICAL_ALIGNMENT
                                                                                                  ));
        }
Ejemplo n.º 11
0
        public virtual void SetMarginTopViaStyleTest()
        {
            float expectedMarginTop = 92;
            Style style             = new Style();

            style.SetMarginTop(expectedMarginTop);
            Paragraph p = new Paragraph("Hello, iText!");

            p.AddStyle(style);
            NUnit.Framework.Assert.AreEqual(UnitValue.CreatePointValue(expectedMarginTop), p.GetProperty <UnitValue>(Property
                                                                                                                     .MARGIN_TOP));
        }
Ejemplo n.º 12
0
        public virtual void SetAndGetHeightUnitValueTest()
        {
            float expectedHeight = 100;
            Style style          = new Style();

            style.SetHeight(UnitValue.CreatePointValue(expectedHeight));
            Paragraph p = new Paragraph();

            p.AddStyle(style);
            NUnit.Framework.Assert.AreEqual(UnitValue.CreatePointValue(expectedHeight), p.GetProperty <UnitValue>(Property
                                                                                                                  .HEIGHT));
        }
Ejemplo n.º 13
0
        public virtual void StylesTest03()
        {
            Style myStyle = new Style();

            myStyle.SetFontColor(ColorConstants.RED);
            Paragraph p = new Paragraph("text").AddStyle(myStyle);

            NUnit.Framework.Assert.AreEqual(ColorConstants.RED, p.GetRenderer().GetProperty <TransparentColor>(Property
                                                                                                               .FONT_COLOR).GetColor());
            Style myStyle2 = new Style();

            myStyle2.SetFontColor(ColorConstants.GREEN);
            p.AddStyle(myStyle2);
            NUnit.Framework.Assert.AreEqual(ColorConstants.GREEN, p.GetRenderer().GetProperty <TransparentColor>(Property
                                                                                                                 .FONT_COLOR).GetColor());
        }
Ejemplo n.º 14
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));
        }
Ejemplo n.º 15
0
 public void CreateSubsectionLabel(string subtitle)
 {
     text = new Paragraph(subtitle);
     text.AddStyle(subSectionStyle);
     document.Add(text);
 }