public virtual void CheckIfOcgForPdfA2Works()
        {
            String fileName    = "createdOcgPdfA.pdf";
            Stream colorStream = new FileStream(sourceFolder + "color/sRGB_CS_profile.icm", FileMode.Open, FileAccess.Read
                                                );
            String      outFileName = destinationFolder + fileName;
            String      cmpFileName = sourceFolder + "cmp/PdfA2LayoutOcgTest/cmp_" + fileName;
            PdfDocument pdfDoc      = new PdfADocument(new PdfWriter(outFileName), PdfAConformanceLevel.PDF_A_2A, new PdfOutputIntent
                                                           ("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", colorStream));

            pdfDoc.SetTagged();
            pdfDoc.GetCatalog().SetLang(new PdfString("en-US"));
            pdfDoc.AddNewPage();
            iText.Layout.Element.Image image1 = new Image(ImageDataFactory.Create(sourceFolder + "images/manualTransparency_for_png.png"
                                                                                  ));
            PdfCanvas pdfCanvas = new PdfCanvas(pdfDoc, 1);

            iText.Layout.Canvas canvas1     = new iText.Layout.Canvas(pdfCanvas, pdfDoc, new Rectangle(0, 0, 590, 420));
            PdfLayer            imageLayer1 = new PdfLayer("*[email protected]", pdfDoc);

            imageLayer1.SetOn(true);
            pdfCanvas.BeginLayer(imageLayer1);
            canvas1.Add(image1);
            pdfCanvas.EndLayer();
            canvas1.Close();
            pdfDoc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             , "diff01_"));
        }
Beispiel #2
0
        protected void ManipulatePdf(String dest)
        {
            PdfDocument     pdfDoc     = new PdfDocument(new PdfWriter(dest));
            Document        doc        = new Document(pdfDoc);
            List <PdfLayer> options    = new List <PdfLayer>();
            PdfLayer        radiogroup = PdfLayer.CreateTitle("Table", pdfDoc);

            PdfLayer radio1 = new PdfLayer("column1", pdfDoc);

            // To follow a "radio button" paradigm,
            // make sure, that no more that one column is selected.
            radio1.SetOn(true);
            options.Add(radio1);
            radiogroup.AddChild(radio1);

            PdfLayer radio2 = new PdfLayer("column2", pdfDoc);

            radio2.SetOn(false);
            options.Add(radio2);
            radiogroup.AddChild(radio2);

            PdfLayer radio3 = new PdfLayer("column3", pdfDoc);

            radio3.SetOn(false);
            options.Add(radio3);
            radiogroup.AddChild(radio3);

            PdfLayer.AddOCGRadioGroup(pdfDoc, options);

            PdfCanvas pdfCanvas = new PdfCanvas(pdfDoc.AddNewPage());

            for (int i = 0; i < 3; i++)
            {
                pdfCanvas.BeginLayer(options[i]);
                Table table = CreateTable(i + 1, options);
                table.SetFixedPosition(1, 36, 700, 523);
                doc.Add(table);
                pdfCanvas.EndLayer();
            }

            doc.Close();
        }
Beispiel #3
0
        public virtual void HandleEvent(Event pdfEvent)
        {
            {
                PdfDocumentEvent docEvent = (PdfDocumentEvent)pdfEvent;
                PdfDocument      pdfDoc   = docEvent.GetDocument();
                Document         document = new Document(pdfDoc);
                PdfPage          page     = docEvent.GetPage();
                int       pageNumber      = pdfDoc.GetPageNumber(page);
                Rectangle pageSize        = page.GetPageSize();

                PdfCanvas pdfCanvas = new PdfCanvas(page.NewContentStreamBefore(), page.GetResources(), pdfDoc);

                //Add header and footer
                PdfFont font = PdfFontFactory.CreateRegisteredFont("calibri-bold");

                if (pageNumber == 1)
                {
                    if (_docOptions.HasFlag(DocConverter.DocOptions.AddHeaderPageOne))
                    {
                        pdfCanvas.SaveState();
                        PdfExtGState state = new PdfExtGState();
                        state.SetFillOpacity(1.0f);
                        pdfCanvas.SetExtGState(state);

                        var imageHeight = _idHeaderFirst.GetHeight() * 72 / 96; //convert pixels to points
                        var imageToAdd  = new Image(_idHeaderFirst, 0, pageSize.GetTop() - imageHeight, pageSize.GetWidth());

                        imageToAdd.GetAccessibilityProperties()
                        .SetAlternateDescription("Background header image");
                        imageToAdd.GetAccessibilityProperties().SetRole(StandardRoles.ARTIFACT);

                        PdfLayer pdflayer = new PdfLayer("main layer", pdfDoc);

                        pdflayer.SetOn(true);
                        Canvas canvas = new Canvas(pdfCanvas, pdfDoc,
                                                   document.GetPageEffectiveArea(pdfDoc.GetDefaultPageSize()));
                        pdflayer.SetPageElement("L");
                        pdfCanvas.BeginLayer(pdflayer);
                        canvas.EnableAutoTagging(page);
                        canvas.Add(imageToAdd);
                        pdfCanvas.EndLayer();
                    }

                    if (_docOptions.HasFlag(DocConverter.DocOptions.DisplayTitle))
                    {
                        //Add Title
                        Color          purpleColor = new DeviceRgb(85, 60, 116);
                        TagTreePointer tagPointer  = new TagTreePointer(pdfDoc);
                        tagPointer.SetPageForTagging(page);
                        tagPointer.AddTag(StandardRoles.TITLE);
                        pdfCanvas.BeginText().SetColor(purpleColor, true).SetFontAndSize(font, 28)
                        .MoveText(42, pageSize.GetTop() - 150).OpenTag(tagPointer.GetTagReference()).ShowText(_title).CloseTag().Stroke();
                    }
                }
                else if (_docOptions.HasFlag(DocConverter.DocOptions.AddHeaderAllPages))
                {
                    pdfCanvas.SaveState();
                    PdfExtGState state = new PdfExtGState();
                    state.SetFillOpacity(1.0f);
                    pdfCanvas.SetExtGState(state);
                    var imageHeight = _idHeaderAll.GetHeight() * 72 / 96; //convert pixels to points
                    var imageToAdd  = new Image(_idHeaderAll, 0, pageSize.GetTop() - imageHeight, pageSize.GetWidth());
                    imageToAdd.GetAccessibilityProperties().SetRole(StandardRoles.ARTIFACT);
                    imageToAdd.GetAccessibilityProperties()
                    .SetAlternateDescription("Background header image");
                    PdfLayer pdflayer = new PdfLayer("main layer", pdfDoc);

                    pdflayer.SetOn(true);

                    Canvas canvas = new Canvas(pdfCanvas, pdfDoc,
                                               document.GetPageEffectiveArea(pdfDoc.GetDefaultPageSize()));

                    pdfCanvas.BeginLayer(pdflayer);
                    canvas.EnableAutoTagging(page);
                    canvas.Add(imageToAdd);
                    pdfCanvas.EndLayer();
                    pdfCanvas.RestoreState();
                }

                if (_docOptions.HasFlag(DocConverter.DocOptions.AddLineBottomEachPage))
                {
                    //Add line to the bottom
                    Color blueColor = new DeviceCmyk(100, 25, 0, 39);

                    pdfCanvas.SetStrokeColor(blueColor)
                    .MoveTo(36, 36)
                    .LineTo(559, 36)
                    .ClosePathStroke();
                }


                pdfCanvas.Release();
            }
        }
Beispiel #4
0
        public Tuple <float, float> AddDependentVowelPage(string c, PdfDocument pdf, Document document, string sIndex)
        {
            const String FONT      = @"C:\Windows\Fonts\STKAITI.TTF";
            PdfFont      fontKaiti = PdfFontFactory.CreateFont(FONT, PdfEncodings.IDENTITY_H, PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED, true);

            //GENERAR CARACTER
            Tuple <float, float> textSize  = SaveBitmapfromFontCharVowel(c, "Kaiti", FontStyle.Regular, sIndex);
            PdfCanvas            pdfCanvas = new PdfCanvas(pdf.AddNewPage());

            Canvas canvas = new Canvas(pdfCanvas, pdf, document.GetPageEffectiveArea(pdf.GetDefaultPageSize()));


            //Layer 1
            PdfLayer pdflayer1 = new PdfLayer("Layer 1", pdf);

            pdflayer1.SetOn(true);
            pdfCanvas.BeginLayer(pdflayer1);

            ///Template IMG
            string template = @"D:\Portada\Cuadernos\PNG A4\Mizige DIN A4 Template HSK - Pie Descripcion 2 lines more.png";

            ImageData data = ImageDataFactory.Create(template);

            iText.Layout.Element.Image img = new iText.Layout.Element.Image(ImageDataFactory.Create(template))
                                             .ScaleToFit(PageSize.A4.GetWidth(), PageSize.A4.GetHeight())
                                             .SetFixedPosition(0, 0);
            canvas.Add(img);
            pdfCanvas.EndLayer();

            //Layer 2 CARACTER GRANDE
            PdfLayer pdflayer2 = new PdfLayer("Layer 2", pdf);

            pdflayer2.SetOn(true);
            pdfCanvas.BeginLayer(pdflayer2);

            int LeftMarginMiZige = 114 * 72 / 300 - 20;
            int UpMarginMiZige   = 114 * 72 / 300 - 5;
            // int CaracterSize = 180;

            int CaracterSize = 200;

            //Este es el path con el que se ha grabado la imagen previamente
            string path = @"D:\KH\KhmerWorkbook\Chars\" + c.ToString() + ".png";

            iText.Layout.Element.Image MainCaracter = new iText.Layout.Element.Image(ImageDataFactory.Create(path))
                                                      .SetFixedPosition(LeftMarginMiZige, PageSize.A4.GetHeight() - CaracterSize - UpMarginMiZige)
                                                      .ScaleAbsolute(CaracterSize, CaracterSize)
                                                      .SetTextAlignment(TextAlignment.CENTER);
            canvas.Add(MainCaracter);
            pdfCanvas.EndLayer();



            //Layer 4 CARACTER PEQUEÑOS FOR
            PdfLayer pdflayer4 = new PdfLayer("Layer 4", pdf);

            pdflayer4.SetOn(true);
            pdfCanvas.BeginLayer(pdflayer4);

            int MiniCaracterSize = 30;
            int MaxColumns       = 17;
            int MaxRows          = 17;

            float width              = 30.6F;
            float height             = 30.7F;
            int   UpMarginMiZigeMini = 22;

            float left   = 0;
            float bottom = 0;

            iText.Layout.Element.Image MiniCaracter = new iText.Layout.Element.Image(ImageDataFactory.Create(path));
            MiniCaracter.ScaleAbsolute(MiniCaracterSize, MiniCaracterSize);
            MiniCaracter.SetTextAlignment(TextAlignment.CENTER);

            for (int col = 0; col < MaxColumns; col++)

            {
                for (int row = 0; row < MaxRows; row++)
                {
                    //No se imprimen donde esta en caracter grande situado
                    if (!(row < 5 && col < 5))
                    {
                        left   = 35 + col * width;
                        bottom = PageSize.A4.GetHeight() - MiniCaracterSize - 2 - UpMarginMiZigeMini - row * height;
                        MiniCaracter.SetFixedPosition(left, bottom);
                        canvas.Add(MiniCaracter);
                    }
                }
            }
            pdfCanvas.EndLayer();

            //INFORMACION CARACTER

            document.SetFont(fontKaiti);

            var   dimensionsColumns = new float[] { 1, 1, 1, 1, 1, 1 };
            Table table             = new Table(UnitValue.CreatePercentArray(dimensionsColumns));

            table.UseAllAvailableWidth();

            PdfLayer pdflayerInfo = new PdfLayer("pdflayerInfo", pdf);

            pdflayerInfo.SetOn(true);
            pdfCanvas.BeginLayer(pdflayerInfo);
            int repeticion = 0;

            List <Paragraph> pGlobals = new List <Paragraph>();

            foreach (Word_HSK word in includedWords)
            {
                //Add row to table
                if (word.Character.Contains(c))
                {
                    repeticion++;

                    Paragraph pGlobal = new Paragraph(word.Character + "\t (" + word.Pinyin + ") , " + word.Type + " , " + word.Description).SetFont(fontKaiti).SetFontSize(10);

                    pGlobals.Add(pGlobal);
                }
            }


            if (repeticion > Maxrepeticion)
            {
                Maxrepeticion = repeticion;
                repeticion    = 0;
                int checkLevel = Level;
            }

            int rowspan = 1;
            int colspan;


            int PalabrasPorFila = 0;

            if (pGlobals.Count <= 4)
            {
                colspan         = 6;
                PalabrasPorFila = 1;
            }
            else if ((pGlobals.Count > 4) && (pGlobals.Count <= 8))
            {
                colspan         = 3;
                PalabrasPorFila = 2;
            }
            else
            {
                colspan         = 2;
                PalabrasPorFila = 3;
            }


            //En blanco antes del numero de pagina

            double Count        = pGlobals.Count;
            double doubleplarba = PalabrasPorFila;
            int    NumeroFilas  = (int)Math.Ceiling(Count / PalabrasPorFila);


            int nwhite = 4 - NumeroFilas;

            int Height  = 14;
            int Columns = 6;                          //Se utiliza para graduar al colspan anterior
            //Celdas en blanco hasta el final del documento
            int FilasBlancasAntesdepalabras = 33 + 4; //Al añadir dos filas mas a la plantilla

            for (int x = 0; x < FilasBlancasAntesdepalabras * Columns; x++)
            {
                Cell cellWhite = new Cell();  // Creating a cell
                cellWhite.SetHeight(Height).Add(new Paragraph(" "));
                table.AddCell(cellWhite);     // Adding cell to the table
            }

            foreach (Paragraph p in pGlobals)
            {
                Cell cellGlobal = new Cell(rowspan, colspan);
                cellGlobal.SetHeight(Height).Add(p);
                table.AddCell(cellGlobal);
            }

            RemoveBorder(table);
            canvas.Add(table);


            Table tableNumberPage = new Table(UnitValue.CreatePercentArray(new float[] { 100 }));

            tableNumberPage.UseAllAvailableWidth();

            for (int x = 0; x < nwhite; x++)
            {
                Cell cellWhite = new Cell();        // Creating a cell
                cellWhite.SetHeight(Height).Add(new Paragraph(" ").SetHeight(Height));
                tableNumberPage.AddCell(cellWhite); // Adding cell to the table
            }

            Cell cellNumberPage = new Cell();   // Creating a cell

            cellNumberPage.SetHeight(Height).Add(new Paragraph(sIndex).SetFontSize(10).SetTextAlignment(TextAlignment.CENTER).SetFont(fontKaiti));
            tableNumberPage.AddCell(cellNumberPage);      // Adding cell to the table

            RemoveBorder(tableNumberPage);
            canvas.Add(tableNumberPage);
            pdfCanvas.EndLayer();


            return(textSize);
        }
        public void AddCaracterPage(string c, PdfDocument pdf, Document document, string sIndex)
        {
            //GENERAR CARACTER
            SaveBitmapfromFontChar(c, "Kaiti", FontStyle.Regular, sIndex);
            PdfCanvas pdfCanvas = new PdfCanvas(pdf.AddNewPage());

            Canvas canvas = new Canvas(pdfCanvas, pdf, document.GetPageEffectiveArea(pdf.GetDefaultPageSize()));


            //Layer 1
            PdfLayer pdflayer1 = new PdfLayer("Layer 1", pdf);

            pdflayer1.SetOn(true);
            pdfCanvas.BeginLayer(pdflayer1);

            ///Template IMG
            string template = @"D:\Portada\Cuadernos\PNG A4\Mizige DIN A4 Template HSK - Pie Descripcion 2 lines more.png";

            ImageData data = ImageDataFactory.Create(template);

            iText.Layout.Element.Image img = new iText.Layout.Element.Image(ImageDataFactory.Create(template))
                                             .ScaleToFit(PageSize.A4.GetWidth(), PageSize.A4.GetHeight())
                                             .SetFixedPosition(0, 0);
            canvas.Add(img);
            pdfCanvas.EndLayer();

            //Layer 2 CARACTER GRANDE
            PdfLayer pdflayer2 = new PdfLayer("Layer 2", pdf);

            pdflayer2.SetOn(true);
            pdfCanvas.BeginLayer(pdflayer2);

            //Para poner una imagen con 300 ppp, use una escala de 72 / 300 = 24 % .Por ejemplo:
            //si tiene una imagen de 5 x 5 pulgadas que escanea a 300 ppp, la
            //imagen resultante es de 1500 x 1500 píxeles(5 x 300 = 1500).Cuando coloca esta imagen en
            //el pdf con una escala del 24 % (72 / 300 = 0.24), la imagen en el pdf será de
            //5X5 pulgadas con 1500X1500 píxeles a 300 dpi.La imagen siempre será de
            //1500X1500 píxeles sea cual sea el tamaño.

            int LeftMarginMiZige = 114 * 72 / 300 - 20;
            int UpMarginMiZige   = 114 * 72 / 300 - 5;
            int CaracterSize     = 180;

            //Este es el path con el que se ha grabado la imagen previamente
            string path = @"D:\HSKBooklet\" + sIndex + "_" + c.ToString() + ".png";

            iText.Layout.Element.Image MainCaracter = new iText.Layout.Element.Image(ImageDataFactory.Create(path))
                                                      .SetFixedPosition(LeftMarginMiZige, PageSize.A4.GetHeight() - CaracterSize - UpMarginMiZige)
                                                      .ScaleAbsolute(CaracterSize, CaracterSize)
                                                      .SetTextAlignment(TextAlignment.CENTER);
            canvas.Add(MainCaracter);
            pdfCanvas.EndLayer();



            //Layer 4 CARACTER PEQUEÑOS FOR
            PdfLayer pdflayer4 = new PdfLayer("Layer 4", pdf);

            pdflayer4.SetOn(true);
            pdfCanvas.BeginLayer(pdflayer4);



            //int MaxColumns = 17;
            //int MaxRows = 26;
            int MiniCaracterSize = 30;
            int MaxColumns       = 17;
            int MaxRows          = 17;

            float width              = 30.6F;
            float height             = 30.7F;
            int   InitialLeftMargin  = 35;
            int   UpMarginMiZigeMini = 22;

            float left   = 0;
            float bottom = 0;

            iText.Layout.Element.Image MiniCaracter = new iText.Layout.Element.Image(ImageDataFactory.Create(path));
            MiniCaracter.ScaleAbsolute(MiniCaracterSize, MiniCaracterSize);
            MiniCaracter.SetTextAlignment(TextAlignment.CENTER);
            MiniCaracter.SetTextAlignment(TextAlignment.CENTER);

            for (int col = 0; col < MaxColumns; col++)

            {
                for (int row = 0; row < MaxRows; row++)
                {
                    //No se imprimen donde esta en caracter grande situado
                    if (!(row < 5 && col < 5))
                    {
                        left   = 35 + col * width;
                        bottom = PageSize.A4.GetHeight() - MiniCaracterSize - 2 - UpMarginMiZigeMini - row * height;

                        //iText.Layout.Element.Image MiniCaracter = new iText.Layout.Element.Image(ImageDataFactory.Create(path))
                        MiniCaracter.SetFixedPosition(left, bottom);
                        canvas.Add(MiniCaracter);
                    }
                }
            }
            pdfCanvas.EndLayer();

            //INFORMACION CARACTER

            //Se incluyen los caracteres no las palabras
            List <Word> arrayIncluded = ToList(includedWords);


            document.SetFont(fontKaiti);

            var   dimensionsColumns = new float[] { 1, 1, 1, 1, 1, 1 };
            Table table             = new Table(UnitValue.CreatePercentArray(dimensionsColumns));

            table.UseAllAvailableWidth();

            PdfLayer pdflayerInfo = new PdfLayer("pdflayerInfo", pdf);

            pdflayerInfo.SetOn(true);
            pdfCanvas.BeginLayer(pdflayerInfo);
            int repeticion = 0;

            List <Paragraph> pGlobals = new List <Paragraph>();

            foreach (Word_HSK word in arrayIncluded)
            {
                //Add row to table
                if (word.Character.Contains(c))
                {
                    repeticion++;

                    Paragraph pGlobal = new Paragraph(word.Character + "\t (" + word.Pinyin + ") , " + word.Description).SetFont(fontKaiti).SetFontSize(10);


                    pGlobals.Add(pGlobal);
                }
            }


            if (repeticion > Maxrepeticion)
            {
                Maxrepeticion = repeticion;
                repeticion    = 0;
                int checkLevel = Level;
            }

            int rowspan = 1;
            int colspan;


            int PalabrasPorFila = 0;

            if (pGlobals.Count <= 4)
            {
                colspan         = 6;
                PalabrasPorFila = 1;
            }
            else if ((pGlobals.Count > 4) && (pGlobals.Count <= 8))
            {
                colspan         = 3;
                PalabrasPorFila = 2;
            }
            else
            {
                colspan         = 2;
                PalabrasPorFila = 3;
            }


            //En blanco antes del numero de pagina

            double Count        = pGlobals.Count;
            double doubleplarba = PalabrasPorFila;
            int    NumeroFilas  = (int)Math.Ceiling(Count / PalabrasPorFila);


            int nwhite = 4 - NumeroFilas;

            int Height  = 14;
            int Columns = 6;                          //Se utiliza para graduar al colspan anterior
            //Celdas en blanco hasta el final del documento
            int FilasBlancasAntesdepalabras = 33 + 4; //Al añadir dos filas mas a la plantilla

            for (int x = 0; x < FilasBlancasAntesdepalabras * Columns; x++)
            {
                Cell cellWhite = new Cell();  // Creating a cell
                cellWhite.SetHeight(Height).Add(new Paragraph(" "));
                table.AddCell(cellWhite);     // Adding cell to the table
            }

            foreach (Paragraph p in pGlobals)
            {
                Cell cellGlobal = new Cell(rowspan, colspan);
                cellGlobal.SetHeight(Height).Add(p);
                table.AddCell(cellGlobal);
            }

            RemoveBorder(table);
            canvas.Add(table);


            Table tableNumberPage = new Table(UnitValue.CreatePercentArray(new float[] { 100 }));

            tableNumberPage.UseAllAvailableWidth();

            for (int x = 0; x < nwhite; x++)
            {
                Cell cellWhite = new Cell();        // Creating a cell
                cellWhite.SetHeight(Height).Add(new Paragraph(" ").SetHeight(Height));
                tableNumberPage.AddCell(cellWhite); // Adding cell to the table
            }

            Cell cellNumberPage = new Cell();   // Creating a cell

            cellNumberPage.SetHeight(Height).Add(new Paragraph(sIndex).SetFontSize(10).SetTextAlignment(TextAlignment.CENTER).SetFont(fontKaiti));
            tableNumberPage.AddCell(cellNumberPage);      // Adding cell to the table

            RemoveBorder(tableNumberPage);
            canvas.Add(tableNumberPage);
            pdfCanvas.EndLayer();
        }
Beispiel #6
0
        protected void ManipulatePdf(String dest)
        {
            PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest));
            PdfCanvas   canvas = new PdfCanvas(pdfDoc.GetFirstPage());

            PdfLayer nested  = new PdfLayer("Nested layers", pdfDoc);
            PdfLayer nested1 = new PdfLayer("Nested layer 1", pdfDoc);
            PdfLayer nested2 = new PdfLayer("Nested layer 2", pdfDoc);

            nested2.SetLocked(true);
            nested.AddChild(nested1);
            nested.AddChild(nested2);

            canvas.BeginLayer(nested);
            Canvas canvasModel = new Canvas(canvas, pdfDoc.GetDefaultPageSize());

            canvasModel.ShowTextAligned("nested layers", 50, 765, TextAlignment.LEFT, 0);
            canvas.EndLayer();

            canvas.BeginLayer(nested1);
            canvasModel.ShowTextAligned("nested layers 1", 100, 800, TextAlignment.LEFT, 0);
            canvas.EndLayer();

            canvas.BeginLayer(nested2);
            canvasModel.ShowTextAligned("nested layers 2", 100, 750, TextAlignment.LEFT, 0);
            canvas.EndLayer();

            PdfLayer group  = PdfLayer.CreateTitle("Grouped layers", pdfDoc);
            PdfLayer layer1 = new PdfLayer("Group: layer 1", pdfDoc);
            PdfLayer layer2 = new PdfLayer("Group: layer 2", pdfDoc);

            group.AddChild(layer1);
            group.AddChild(layer2);

            canvas.BeginLayer(layer1);
            canvasModel.ShowTextAligned("layer 1 in the group", 50, 700, TextAlignment.LEFT, 0);
            canvas.EndLayer();

            canvas.BeginLayer(layer2);
            canvasModel.ShowTextAligned("layer 2 in the group", 50, 675, TextAlignment.LEFT, 0);
            canvas.EndLayer();

            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);

            canvas.BeginLayer(radio1);
            canvasModel.ShowTextAligned("option 1", 50, 600, TextAlignment.LEFT, 0);
            canvas.EndLayer();

            canvas.BeginLayer(radio2);
            canvasModel.ShowTextAligned("option 2", 50, 575, TextAlignment.LEFT, 0);
            canvas.EndLayer();

            canvas.BeginLayer(radio3);
            canvasModel.ShowTextAligned("option 3", 50, 550, TextAlignment.LEFT, 0);
            canvas.EndLayer();

            PdfLayer not_printed = new PdfLayer("not printed", pdfDoc);

            not_printed.SetOnPanel(false);
            not_printed.SetPrint("Print", false);

            canvas.BeginLayer(not_printed);
            canvasModel.ShowTextAligned("PRINT THIS PAGE", 300, 700, TextAlignment.CENTER,
                                        (float)MathUtil.ToRadians(90));
            canvas.EndLayer();

            PdfLayer zoom = new PdfLayer("Zoom 0.75-1.25", pdfDoc);

            zoom.SetOnPanel(false);
            zoom.SetZoom(0.75f, 1.25f);

            canvas.BeginLayer(zoom);
            canvasModel.ShowTextAligned("Only visible if the zoomfactor is between 75 and 125%",
                                        30, 530, TextAlignment.LEFT, (float)MathUtil.ToRadians(90));
            canvas.EndLayer();

            pdfDoc.Close();
        }