public virtual void BorderWidthIndentMultilineTest()
        {
            String           filename = destinationFolder + "borderWidthIndentMultilineTest.pdf";
            PdfDocument      pdfDoc   = new PdfDocument(new PdfWriter(filename));
            PdfAcroForm      form     = PdfAcroForm.GetAcroForm(pdfDoc, true);
            PdfTextFormField field    = PdfFormField.CreateMultilineText(pdfDoc, new Rectangle(100, 500, 400, 300), "multi"
                                                                         , "Does this text overlap the border? Well it shouldn't!");

            field.SetFontSize(30);
            field.SetBorderColor(ColorConstants.RED);
            field.SetBorderWidth(50);
            form.AddField(field);
            PdfTextFormField field2 = PdfFormField.CreateMultilineText(pdfDoc, new Rectangle(100, 400, 400, 50), "multiAuto"
                                                                       , "Does this autosize text overlap the border? Well it shouldn't! Does it fit accurately though?");

            field2.SetFontSize(0);
            field2.SetBorderColor(ColorConstants.RED);
            field2.SetBorderWidth(20);
            form.AddField(field2);
            pdfDoc.Close();
            CompareTool compareTool  = new CompareTool();
            String      errorMessage = compareTool.CompareByContent(filename, sourceFolder + "cmp_borderWidthIndentMultilineTest.pdf"
                                                                    , destinationFolder, "diff_");

            if (errorMessage != null)
            {
                NUnit.Framework.Assert.Fail(errorMessage);
            }
        }
Пример #2
0
            override public void Draw(DrawContext drawContext)
            {
                base.Draw(drawContext);
                iText.Kernel.Geom.Rectangle cuadro = GetOccupiedAreaBBox();
                cuadro.MoveUp(margenExterior).MoveRight(margenExterior);
                cuadro.SetHeight(cuadro.GetHeight() - (margenExterior * 2));
                cuadro.SetWidth(cuadro.GetWidth() - (margenExterior * 2));
                PdfTextFormField field = PdfFormField.CreateText(drawContext.GetDocument(), cuadro, fieldName, valor);

                field.SetJustification(justificacion);
                field.SetVisibility(PdfFormField.VISIBLE);
                field.SetFontSize(fontSize);
                PdfAcroForm form = PdfAcroForm.GetAcroForm(drawContext.GetDocument(), true);

                form.AddField(field);
            }