Пример #1
0
        public virtual void LayersRadioGroup()
        {
            String      outPdf     = destinationFolder + "layersRadioGroup.pdf";
            String      cmpPdf     = sourceFolder + "cmp_layersRadioGroup.pdf";
            PdfDocument pdfDoc     = new PdfDocument(new PdfWriter(outPdf));
            PdfFont     font       = PdfFontFactory.CreateFont();
            PdfLayer    radiogroup = PdfLayer.CreateTitle("Radio group", pdfDoc);
            PdfLayer    radio1     = new PdfLayer("Radiogroup: layer 1", pdfDoc);

            radio1.SetOn(true);
            PdfLayer radio2 = new PdfLayer("Radiogroup: layer 2", pdfDoc);

            radio2.SetOn(false);
            PdfLayer radio3 = new PdfLayer("Radiogroup: layer 3", pdfDoc);

            radio3.SetOn(false);
            radiogroup.AddChild(radio1);
            radiogroup.AddChild(radio2);
            radiogroup.AddChild(radio3);
            IList <PdfLayer> options = new List <PdfLayer>();

            options.Add(radio1);
            options.Add(radio2);
            options.Add(radio3);
            PdfLayer.AddOCGRadioGroup(pdfDoc, options);
            PdfCanvas canvas = new PdfCanvas(pdfDoc.AddNewPage());

            canvas.SetFontAndSize(font, 12);
            PdfLayerTestUtils.AddTextInsideLayer(radio1, canvas, "layer option 1", 50, 600);
            PdfLayerTestUtils.AddTextInsideLayer(radio2, canvas, "layer option 2", 50, 575);
            PdfLayerTestUtils.AddTextInsideLayer(radio3, canvas, "layer option 3", 50, 550);
            pdfDoc.Close();
            PdfLayerTestUtils.CompareLayers(outPdf, cmpPdf);
        }