public virtual void MultiSelectByValueTest()
        {
            String      outPdf   = destinationFolder + "multiSelectByValueTest.pdf";
            String      cmpPdf   = sourceFolder + "cmp_multiSelectByValueTest.pdf";
            PdfDocument document = new PdfDocument(new PdfWriter(outPdf));

            document.AddNewPage();
            PdfAcroForm        form   = PdfAcroForm.GetAcroForm(document, true);
            PdfChoiceFormField choice = (PdfChoiceFormField)PdfFormField.CreateList(document, new Rectangle(336, 666,
                                                                                                            50, 80), "choice", "two", new String[] { "one", "two", "three", "four" }, null, null).SetBorderColor(ColorConstants
                                                                                                                                                                                                                 .BLACK);

            choice.SetMultiSelect(true);
            choice.SetListSelected(new String[] { "one", "three", "eins", "drei" });
            NUnit.Framework.Assert.AreEqual(new int[] { 0, 2 }, choice.GetIndices().ToIntArray());
            PdfArray values = (PdfArray)choice.GetValue();

            String[] valuesAsStrings = new String[values.Size()];
            for (int i = 0; i < values.Size(); i++)
            {
                valuesAsStrings[i] = values.GetAsString(i).ToUnicodeString();
            }
            NUnit.Framework.Assert.AreEqual(new String[] { "one", "three", "eins", "drei" }, valuesAsStrings);
            form.AddField(choice);
            document.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder));
        }
        public virtual void MultiSelectByIndexOutOfBoundsTest()
        {
            String             srcPdf   = sourceFolder + "multiSelectTest.pdf";
            String             outPdf   = destinationFolder + "multiSelectByIndexOutOfBoundsTest.pdf";
            String             cmpPdf   = sourceFolder + "cmp_multiSelectByIndexOutOfBoundsTest.pdf";
            PdfDocument        document = new PdfDocument(new PdfReader(srcPdf), new PdfWriter(outPdf));
            PdfAcroForm        form     = PdfAcroForm.GetAcroForm(document, false);
            PdfChoiceFormField field    = (PdfChoiceFormField)form.GetField("choice");

            field.SetListSelected(new int[] { 5 });
            document.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder));
        }
        public virtual void CorruptedOptAndValueSetToNullTest()
        {
            String             srcPdf   = sourceFolder + "corruptedOptAndValueSetToNullTest.pdf";
            String             outPdf   = destinationFolder + "corruptedOptAndValueSetToNullTest.pdf";
            String             cmpPdf   = sourceFolder + "cmp_corruptedOptAndValueSetToNullTest.pdf";
            PdfDocument        document = new PdfDocument(new PdfReader(srcPdf), new PdfWriter(outPdf));
            PdfAcroForm        form     = PdfAcroForm.GetAcroForm(document, false);
            PdfChoiceFormField choice   = (PdfChoiceFormField)form.GetField("choice");

            choice.SetListSelected(new String[] { null, "three" });
            document.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder));
        }
        public virtual void TopIndexTest()
        {
            String             srcPdf   = sourceFolder + "choiceFieldNotFittingTest.pdf";
            String             outPdf   = destinationFolder + "topIndexTest.pdf";
            String             cmpPdf   = sourceFolder + "cmp_topIndexTest.pdf";
            PdfDocument        document = new PdfDocument(new PdfReader(srcPdf), new PdfWriter(outPdf));
            PdfAcroForm        form     = PdfAcroForm.GetAcroForm(document, false);
            PdfChoiceFormField field    = (PdfChoiceFormField)form.GetField("choice");

            field.SetListSelected(new String[] { "seven" });
            int topIndex = field.GetIndices().GetAsNumber(0).IntValue();

            field.SetTopIndex(topIndex);
            document.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder));
        }
        public virtual void PdfA1DocWithPdfA1ListFieldTest()
        {
            String  name         = "pdfA1DocWithPdfA1ListField";
            String  fileName     = destinationFolder + name + ".pdf";
            String  cmp          = sourceFolder + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ListField.pdf";
            PdfFont fontFreeSans = PdfFontFactory.CreateFont(sourceFolder + "FreeSans.ttf", "WinAnsi", true);
            Stream  @is          = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
            PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_1B;
            PdfADocument         pdfDoc           = new PdfADocument(new PdfWriter(fileName), conformanceLevel, new PdfOutputIntent("Custom"
                                                                                                                                    , "", "http://www.color.org", "sRGB IEC61966-2.1", @is));
            PdfAcroForm        form = PdfAcroForm.GetAcroForm(pdfDoc, true);
            PdfChoiceFormField f    = PdfFormField.CreateList(pdfDoc, new Rectangle(86, 556, 50, 200), "list", "9", new String
                                                              [] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }, fontFreeSans, conformanceLevel);

            f.SetValue("4");
            f.SetTopIndex(2);
            f.SetListSelected(new String[] { "3", "5" });
            form.AddField(f);
            pdfDoc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(fileName, cmp, destinationFolder));
            NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(fileName));
        }