Exemplo n.º 1
0
        public virtual void ListItemTest02()
        {
            String      outFileName = destinationFolder + "listItemTest02.pdf";
            String      cmpFileName = sourceFolder + "cmp_listItemTest02.pdf";
            PdfDocument pdf         = new PdfDocument(new PdfWriter(outFileName));
            Document    document    = new Document(pdf);

            document.SetFontColor(ColorConstants.WHITE);
            List  list    = new List();
            Style liStyle = new Style().SetMargins(20, 0, 20, 0).SetBackgroundColor(ColorConstants.BLACK);

            list.Add((ListItem) new ListItem("").AddStyle(liStyle)).Add((ListItem) new ListItem("fox").AddStyle(liStyle)
                                                                        ).Add((ListItem) new ListItem("").AddStyle(liStyle)).Add((ListItem) new ListItem("dog").AddStyle(liStyle
                                                                                                                                                                         ));
            document.Add(list.SetBackgroundColor(ColorConstants.BLUE));
            document.Add(new Paragraph("separation between lists"));
            liStyle.SetMargin(0);
            document.Add(list);
            document.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             , "diff"));
        }
Exemplo n.º 2
0
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        private void ElementOpacityTest(String elem)
        {
            String      outFileName     = destinationFolder + elem + "ElementOpacity01.pdf";
            String      cmpFileName     = sourceFolder + "cmp_" + elem + "ElementOpacity01.pdf";
            PdfDocument pdfDocument     = new PdfDocument(new PdfWriter(outFileName));
            Document    document        = new Document(pdfDocument);
            DeviceRgb   divBackground   = WebColors.GetRGBColor("#82abd6");
            DeviceRgb   paraBackground  = WebColors.GetRGBColor("#994ec7");
            DeviceRgb   textBackground  = WebColors.GetRGBColor("#009688");
            DeviceRgb   tableBackground = WebColors.GetRGBColor("#ffc107");

            document.SetFontColor(ColorConstants.WHITE);
            Div div = new Div().SetBackgroundColor(divBackground);

            if ("div".Equals(elem))
            {
                div.SetOpacity(0.3f);
            }
            div.Add(new Paragraph("direct div content"));
            Paragraph p = new Paragraph("direct paragraph content").SetBackgroundColor(paraBackground);

            if ("para".Equals(elem))
            {
                p.SetOpacity(0.3f);
            }
            Text text = new Text("text content").SetBackgroundColor(textBackground);

            p.Add(text);
            if ("text".Equals(elem))
            {
                text.SetOpacity(0.3f);
            }
            div.Add(p);
            iText.Layout.Element.Image image = new Image(ImageDataFactory.Create(sourceFolder + "itis.jpg"));
            div.Add(image);
            if ("image".Equals(elem))
            {
                image.SetOpacity(0.3f);
            }
            Table table = new Table(UnitValue.CreatePercentArray(2)).UseAllAvailableWidth().SetBackgroundColor(tableBackground
                                                                                                               );

            table.AddCell("Cell00");
            table.AddCell("Cell01");
            Cell cell10 = new Cell().Add(new Paragraph("Cell10"));

            if ("cell".Equals(elem))
            {
                cell10.SetOpacity(0.3f);
            }
            table.AddCell(cell10);
            table.AddCell(new Cell().Add(new Paragraph("Cell11")));
            if ("table".Equals(elem))
            {
                table.SetOpacity(0.3f);
            }
            div.Add(table);
            List list = new List();

            if ("list".Equals(elem))
            {
                list.SetOpacity(0.3f);
            }
            ListItem listItem = new ListItem("item 0");

            list.Add(listItem);
            if ("listItem".Equals(elem))
            {
                listItem.SetOpacity(0.3f);
            }
            list.Add("item 1");
            div.Add(list);
            document.Add(div);
            document.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             , "diff"));
        }