public void PageSizeA3()
        {
            Document doc = new Document();
            Page     pg  = new Page();

            pg.PaperSize = PaperSize.A3;
            doc.Pages.Add(pg);

            pg.Contents.Add(new TextLiteral("A3"));
            pg.HorizontalAlignment = HorizontalAlignment.Center;
            pg.VerticalAlignment   = VerticalAlignment.Top;
            pg.FontSize            = 30;
            pg.Margins             = new Scryber.Drawing.PDFThickness(20);

            doc.ViewPreferences.PageLayout = PageLayoutMode.SinglePage;

            using (var ms = DocStreams.GetOutputStream("PageSizeA3.pdf"))
            {
                doc.LayoutComplete += Doc_LayoutDocument;
                doc.SaveAsPDF(ms);
            }

            PDFLayoutPage layoutPg = layoutDoc.AllPages[0];

            Assert.AreEqual((int)layoutPg.Width.ToMillimeters().Value, 297);
            Assert.AreEqual((int)layoutPg.Height.ToMillimeters().Value, 420);
        }
        public void Default_Numbered_Test()
        {
            Document doc        = new Document();
            int      totalcount = 10;

            //Add ten pages with default numbering
            for (int i = 0; i < totalcount; i++)
            {
                Page pg = new Page();
                doc.Pages.Add(pg);
                PageNumberLabel lbl = new PageNumberLabel();
                pg.Contents.Add(lbl);
            }

            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
            {
                doc.LayoutComplete += Doc_LayoutCompleted;
                doc.SaveAsPDF(ms);
            }

            for (int i = 0; i < totalcount; i++)
            {
                int           pgNum = i + 1;
                PDFLayoutPage lpg   = layout.AllPages[i];

                PDFPageNumberData data = lpg.GetPageNumber();

                //Check the number
                Assert.AreEqual(pgNum, data.PageNumber);
                Assert.AreEqual(totalcount, data.LastPageNumber);
                Assert.AreEqual(pgNum, data.GroupNumber);
                Assert.AreEqual(totalcount, data.GroupLastNumber);
                Assert.AreEqual(pgNum.ToString(), data.ToString());
            }
        }
        public void PanelWithMinWidthAndHeight()
        {
            Document doc = new Document();
            Page     pg  = new Page();

            pg.Style.PageStyle.Width  = PageWidth;
            pg.Style.PageStyle.Height = PageHeight;

            doc.Pages.Add(pg);

            int expectedMinWidth  = 200;
            int expectedMinHeight = 50;

            Panel panel = new Panel();

            panel.MinimumWidth  = expectedMinWidth;
            panel.MinimumHeight = expectedMinHeight;
            panel.BorderColor   = Scryber.Drawing.PDFColors.Black;
            pg.Contents.Add(panel);


            Label lbl = new Label()
            {
                Text = "Not wide enough"
            };

            panel.Contents.Add(lbl); //Will not push the panel beyond its minimumn width


            using (var ms = DocStreams.GetOutputStream("PanelsMinWidthAndHeight.pdf"))
            {
                doc.LayoutComplete += Doc_LayoutComplete;
                doc.SaveAsPDF(ms);
            }

            PDFLayoutPage   layoutpg    = layout.AllPages[0];
            PDFLayoutBlock  pgcontent   = layoutpg.ContentBlock;
            PDFLayoutRegion pgregion    = pgcontent.Columns[0];
            PDFLayoutBlock  panelBlock  = pgregion.Contents[0] as PDFLayoutBlock;
            PDFLayoutRegion panelregion = panelBlock.Columns[0];

            Assert.IsNotNull(panelBlock, "The layout block in the page column should not be null");

            //block width and height should be the minimums
            Assert.AreEqual(expectedMinWidth, panelBlock.Width, "Panel block should be " + expectedMinWidth + " wide");
            Assert.AreEqual(expectedMinHeight, panelBlock.Height, "Panel block should be " + expectedMinHeight + " high");

            //Total bounds
            Assert.AreEqual(expectedMinWidth, panelBlock.TotalBounds.Width, "Panel block total width should be " + expectedMinWidth);
            Assert.AreEqual(expectedMinHeight, panelBlock.TotalBounds.Height, "Panel block total height should be " + expectedMinHeight);
            Assert.AreEqual(0, panelBlock.TotalBounds.X, "Panel block total X should be 0");
            Assert.AreEqual(0, panelBlock.TotalBounds.Y, "Panel block total Y should be 0");

            Assert.IsTrue(expectedMinWidth > panelregion.TotalBounds.Width, "Panel region total width should be less than " + expectedMinWidth);
            Assert.IsTrue(expectedMinHeight > panelregion.TotalBounds.Height, "Panel region total height should be less than " + expectedMinHeight);
            Assert.AreEqual(0, panelregion.TotalBounds.X, "Panel region total X should be 0");
            Assert.AreEqual(0, panelregion.TotalBounds.Y, "Panel region total Y should be 0");
        }
示例#4
0
        public void SectionOverflow()
        {
            const int PageWidth  = 200;
            const int PageHeight = 300;

            Document doc     = new Document();
            Section  section = new Section();

            section.Style.PageStyle.Width  = PageWidth;
            section.Style.PageStyle.Height = PageHeight;
            doc.Pages.Add(section);

            Div top = new Div()
            {
                Height = PageHeight - 100
            };

            section.Contents.Add(top);

            //div is too big for the remaining space on the page
            Div tooverflow = new Div()
            {
                Height = 150
            };

            section.Contents.Add(tooverflow);

            using (var ms = DocStreams.GetOutputStream("SectionOverflow.pdf"))
            {
                doc.LayoutComplete += Doc_LayoutComplete;
                doc.SaveAsPDF(ms);
            }

            Assert.AreEqual(2, layout.AllPages.Count);


            //Check that the first page has the same dimensions.
            PDFLayoutPage firstpage = layout.AllPages[0];

            Assert.AreEqual(PageWidth, firstpage.Width);
            Assert.AreEqual(PageHeight, firstpage.Height);


            //Check that the overflowed page has the same dimensions.
            PDFLayoutPage lastpage = layout.AllPages[1];

            Assert.AreEqual(PageWidth, lastpage.Width);
            Assert.AreEqual(PageHeight, lastpage.Height);

            //Check that the block has overflowed to 0 y offset
            PDFLayoutBlock overflowedblock = lastpage.ContentBlock.Columns[0].Contents[0] as PDFLayoutBlock;

            Assert.AreEqual(0, overflowedblock.TotalBounds.Y);
            Assert.AreEqual(150, overflowedblock.Height);
        }
        public void DefaultWithSection_Numbered_Test()
        {
            Document doc        = new Document();
            int      totalcount = 10;

            //Add ten pages with default numbering
            for (int i = 0; i < totalcount; i++)
            {
                if (i == 5)
                {
                    Section section = new Section();
                    section.PageNumberStyle = PageNumberStyle.UppercaseLetters;

                    doc.Pages.Add(section);

                    for (int j = 0; j < 4; j++) //4 page breaks = 5 pages
                    {
                        PageBreak br = new PageBreak();
                        section.Contents.Add(br);
                    }
                }
                else
                {
                    Page pg = new Page();
                    doc.Pages.Add(pg);
                    PageNumberLabel lbl = new PageNumberLabel();
                    pg.Contents.Add(lbl);
                }
            }


            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
            {
                doc.LayoutComplete += Doc_LayoutCompleted;
                doc.SaveAsPDF(ms);
            }
            string[] allpages = new string[] { "1", "2", "3", "4", "5", "A", "B", "C", "D", "E", "6", "7", "8", "9" };
            string[] grptotal = new string[] { "5", "5", "5", "5", "5", "E", "E", "E", "E", "E", "9", "9", "9", "9" };

            for (int i = 0; i < allpages.Length; i++)
            {
                string expected = string.Format("Page {0} of {1} ({2} of {3})", allpages[i], grptotal[i], i + 1, allpages.Length);

                PDFLayoutPage     lpg  = layout.AllPages[i];
                PDFPageNumberData data = lpg.GetPageNumber();

                string actual = data.ToString("Page {0} of {1} ({2} of {3})");
                Assert.AreEqual(expected, actual);
                TestContext.WriteLine("Expected '{0}', Actual '{1}'", expected, actual);
            }
        }
        public void PanelBeyondMinWidthAndHeight()
        {
            Document doc = new Document();
            Page     pg  = new Page();

            pg.Style.PageStyle.Width  = PageWidth;
            pg.Style.PageStyle.Height = PageHeight;
            pg.Style.Font.FontSize    = 18;

            doc.Pages.Add(pg);

            int expectedMinWidth  = 200;
            int expectedMinHeight = 100;

            Panel panel = new Panel();

            panel.MinimumWidth  = expectedMinWidth;
            panel.MinimumHeight = expectedMinHeight;
            panel.BorderColor   = Scryber.Drawing.PDFColors.Black;
            pg.Contents.Add(panel);

            Label lbl = new Label()
            {
                Text = "This label is wide enough to go beyond the 200pt minimum width of the panel " +
                       "and also the width of the page, so should flow onto the next line and keep going beyond the minimum height of the " +
                       "panel. Therefore extending beyond the bounds of both min- values."
            };

            panel.Contents.Add(lbl); //WILL push the panel beyond its minimumn width


            using (var ms = DocStreams.GetOutputStream("PanelsBeyondMinWidthAndHeight.pdf"))
            {
                doc.LayoutComplete += Doc_LayoutComplete;
                doc.SaveAsPDF(ms);
            }

            PDFLayoutPage   layoutpg    = layout.AllPages[0];
            PDFLayoutBlock  pgcontent   = layoutpg.ContentBlock;
            PDFLayoutRegion pgregion    = pgcontent.Columns[0];
            PDFLayoutBlock  panelBlock  = pgregion.Contents[0] as PDFLayoutBlock;
            PDFLayoutRegion panelregion = panelBlock.Columns[0];

            Assert.IsNotNull(panelBlock, "The layout block in the page column should not be null");

            //block width and height should be greater than the minimum width, but not beyond the height.
            Assert.IsTrue(expectedMinWidth < panelBlock.Width, "Panel block should be greater than " + expectedMinWidth + " wide");
            Assert.IsTrue(PageWidth > panelBlock.Width, "Panel block should not go beyond the page width");
            Assert.IsTrue(expectedMinHeight < panelBlock.Height, "Panel block should be greater than " + panelBlock.Height + " high");
        }
        public void DocumentPrefixUpperAlpha_Numbered_Test()
        {
            Document doc = new Document();

            //Add a catch all number style definition for upper letter with Prefix
            StyleDefn pgNumStyle = new StyleDefn();

            pgNumStyle.AppliedType = typeof(Document);

            pgNumStyle.PageStyle.NumberStyle = PageNumberStyle.UppercaseLetters;
            doc.Styles.Add(pgNumStyle);


            int totalcount = 10;

            //Add ten pages with default numbering
            for (int i = 0; i < totalcount; i++)
            {
                Page pg = new Page();
                doc.Pages.Add(pg);
                PageNumberLabel lbl = new PageNumberLabel();
                pg.Contents.Add(lbl);
            }


            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
            {
                doc.LayoutComplete += Doc_LayoutCompleted;
                doc.SaveAsPDF(ms);
            }

            //Check the numbers
            for (int i = 0; i < totalcount; i++)
            {
                int           pgNum = i + 1;
                PDFLayoutPage lpg   = layout.AllPages[i];

                PDFPageNumberData data = lpg.GetPageNumber();

                //Check the number
                Assert.AreEqual(pgNum, data.PageNumber, "Page Number failed");
                Assert.AreEqual(totalcount, data.LastPageNumber, "Last Page number failed");
                Assert.AreEqual(pgNum, data.GroupNumber, "Group number failed");
                Assert.AreEqual(totalcount, data.GroupLastNumber, "Last Group number failed");

                //Should be upper letter with hash prefix
                string output = ((char)((int)'A' + i)).ToString();
                Assert.AreEqual(output, data.ToString(), "String result failed");
            }
        }
        public void PageWithMarginsPaddingAndFullWidthPanelWithMarginsAndPadding()
        {
            Document doc = new Document();
            Page     pg  = new Page();

            pg.Style.PageStyle.Width  = PageWidth;
            pg.Style.PageStyle.Height = PageHeight;

            int margin  = 20;
            int padding = 10;

            pg.Style.Padding.All = padding;
            pg.Style.Margins.All = margin;

            doc.Pages.Add(pg);

            int explicitHeight = 50;



            Panel panel = new Panel();

            panel.FullWidth         = true;
            panel.Height            = explicitHeight;
            panel.Style.Margins.All = margin;
            panel.Style.Padding.All = padding;
            panel.BorderColor       = Scryber.Drawing.PDFColors.Black;
            pg.Contents.Add(panel);



            using (var ms = DocStreams.GetOutputStream("PanelsFullWidthWithSpacingBoth.pdf"))
            {
                doc.LayoutComplete += Doc_LayoutComplete;
                doc.SaveAsPDF(ms);
            }

            PDFLayoutPage   layoutpg = layout.AllPages[0];
            PDFLayoutBlock  content  = layoutpg.ContentBlock;
            PDFLayoutRegion region   = content.Columns[0];

            //Panel in page content region
            PDFLayoutBlock panelBlock = region.Contents[0] as PDFLayoutBlock;

            Assert.IsNotNull(panelBlock, "The layout block in the page column should not be null");

            //Expected measurements of the panel block

            //Width of fullwidth panel is reduced by margins and padding
            int expectedWidth = PageWidth - ((2 * margin) + (2 * padding));

            //Actual height of the panel is explicit height + the margins
            int expectedHeight = explicitHeight + (2 * margin);

            //Position of panel is zero - margins and padding are accounted for when rendering
            int expectedX = 0;
            int expectedY = 0;

            //Panel width and height
            Assert.AreEqual(expectedWidth, panelBlock.Width, "Panel block should be " + expectedWidth + " wide");
            Assert.AreEqual(expectedHeight, panelBlock.Height, "Panel block should be " + expectedHeight + " high");

            //Panel Block Total bounds
            Assert.AreEqual(expectedWidth, panelBlock.TotalBounds.Width, "Panel block total width should be " + expectedWidth);
            Assert.AreEqual(expectedHeight, panelBlock.TotalBounds.Height, "Panel block total height should be " + expectedHeight);
            Assert.AreEqual(expectedX, panelBlock.TotalBounds.X, "Panel block total X should be " + expectedX);
            Assert.AreEqual(expectedY, panelBlock.TotalBounds.Y, "Panel block total Y should be " + expectedY);

            //As we have both padding and margins on the panel width and height are reduced for the available space.
            expectedWidth  = (int)panelBlock.TotalBounds.Width.PointsValue - ((2 * margin) + (2 * padding));
            expectedHeight = (int)panelBlock.TotalBounds.Height.PointsValue - ((2 * margin) + (2 * padding));

            //X and Y of the available bounds (and also the inner region content) are offset by the padding.
            expectedX = padding + margin;
            expectedY = padding + margin;

            //Panel Block Available bounds
            Assert.AreEqual(expectedWidth, panelBlock.AvailableBounds.Width, "Panel block available width should be " + expectedWidth);
            Assert.AreEqual(expectedHeight, panelBlock.AvailableBounds.Height, "Panel block available height should be " + expectedHeight);
            Assert.AreEqual(expectedX, panelBlock.AvailableBounds.X, "Panel block available X should be " + expectedX);
            Assert.AreEqual(expectedY, panelBlock.AvailableBounds.Y, "Panel block available Y should be " + expectedY);


            //Panel inner region
            Assert.IsTrue(panelBlock.Columns.Length == 1, "There should be one region in the panel block");
            region = panelBlock.Columns[0];

            //region Total bounds
            Assert.AreEqual(expectedWidth, region.TotalBounds.Width, "Panel region total width should be " + expectedWidth);
            Assert.AreEqual(expectedHeight, region.TotalBounds.Height, "Panel region total height should be " + expectedHeight);
            Assert.AreEqual(0, region.TotalBounds.X, "Panel region total X should be 0");
            Assert.AreEqual(0, region.TotalBounds.Y, "Panel region total Y should be 0");

            //region Unused bounds
            Assert.AreEqual(expectedWidth, region.UnusedBounds.Width, "Panel region unused width should be " + expectedWidth);
            Assert.AreEqual(expectedHeight, region.UnusedBounds.Height, "Panel region unused height should be " + expectedHeight);
            Assert.AreEqual(0, region.UnusedBounds.X, "Panel region unused X should be 0");
            Assert.AreEqual(0, region.UnusedBounds.Y, "Panel region unused Y should be 0");

            //region Used Size
            Assert.AreEqual(0, region.UsedSize.Height, "Panel region used height should be 0");
            Assert.AreEqual(0, region.UsedSize.Width, "Panel region used width should be 0");

            //Region Offset and available height
            Assert.AreEqual(0, region.OffsetX, "Panel region offsetX should be 0");
            Assert.AreEqual(expectedHeight, region.AvailableHeight, "Panel region available height should be " + expectedHeight);
        }
        public void PageWithExplicitSizedPanel()
        {
            Document doc = new Document();
            Page     pg  = new Page();

            pg.Style.PageStyle.Width  = PageWidth;
            pg.Style.PageStyle.Height = PageHeight;

            doc.Pages.Add(pg);

            int expectedWidth  = 100;
            int expectedHeight = 50;

            Panel panel = new Panel();

            panel.Width       = expectedWidth;
            panel.Height      = expectedHeight;
            panel.BorderColor = Scryber.Drawing.PDFColors.Black;
            pg.Contents.Add(panel);


            using (var ms = DocStreams.GetOutputStream("PanelsExplicitSizing.pdf"))
            {
                doc.LayoutComplete += Doc_LayoutComplete;
                doc.SaveAsPDF(ms);
            }

            Assert.AreEqual(1, layout.AllPages.Count, "There should be only 1 page");
            PDFLayoutPage layoutpg = layout.AllPages[0];

            //Page content block
            PDFLayoutBlock content = layoutpg.ContentBlock;

            Assert.IsTrue(content.Columns.Length == 1, "There should be only 1 column");

            //Page content region
            PDFLayoutRegion region = content.Columns[0];

            Assert.IsTrue(region.Contents.Count == 1, "There should be only one item in the region contents");

            //Panel in content
            PDFLayoutBlock panelBlock = region.Contents[0] as PDFLayoutBlock;

            Assert.IsNotNull(panelBlock, "The layout block in the page column should not be null");

            //Panel width and height
            Assert.AreEqual(expectedWidth, panelBlock.Width, "Panel block should be " + expectedWidth + " wide");
            Assert.AreEqual(expectedHeight, panelBlock.Height, "Panel block should be " + expectedHeight + " high");

            //Total bounds
            Assert.AreEqual(expectedWidth, panelBlock.TotalBounds.Width, "Panel block total width should be " + expectedWidth);
            Assert.AreEqual(expectedHeight, panelBlock.TotalBounds.Height, "Panel block total height should be " + expectedHeight);
            Assert.AreEqual(0, panelBlock.TotalBounds.X, "Panel block total X should be 0");
            Assert.AreEqual(0, panelBlock.TotalBounds.Y, "Panel block total Y should be 0");

            //Available bounds
            Assert.AreEqual(expectedWidth, panelBlock.AvailableBounds.Width, "Panel block available width should be " + expectedWidth);
            Assert.AreEqual(expectedHeight, panelBlock.AvailableBounds.Height, "Panel block available height should be " + expectedHeight);
            Assert.AreEqual(0, panelBlock.AvailableBounds.X, "Panel block available X should be 0");
            Assert.AreEqual(0, panelBlock.AvailableBounds.Y, "Panel block available Y should be 0");

            //Panel inner region
            Assert.IsTrue(panelBlock.Columns.Length == 1, "There should be one region in the panel block");
            region = panelBlock.Columns[0];

            //region Total bounds
            Assert.AreEqual(expectedWidth, region.TotalBounds.Width, "Panel region total width should be " + expectedWidth);
            Assert.AreEqual(expectedHeight, region.TotalBounds.Height, "Panel region total height should be " + expectedHeight);
            Assert.AreEqual(0, region.TotalBounds.X, "Panel region total X should be 0");
            Assert.AreEqual(0, region.TotalBounds.Y, "Panel region total Y should be 0");

            //region Unused bounds
            Assert.AreEqual(expectedWidth, region.UnusedBounds.Width, "Panel region unused width should be " + expectedWidth);
            Assert.AreEqual(expectedHeight, region.UnusedBounds.Height, "Panel region unused height should be " + expectedHeight);
            Assert.AreEqual(0, region.UnusedBounds.X, "Panel region unused X should be 0");
            Assert.AreEqual(0, region.UnusedBounds.Y, "Panel region unused Y should be 0");

            //region Used Size
            Assert.AreEqual(0, region.UsedSize.Height, "Panel region used height should be 0");
            Assert.AreEqual(0, region.UsedSize.Width, "Panel region used width should be 0");

            //Region Offset and available height
            Assert.AreEqual(0, region.OffsetX, "Panel region offsetX should be 0");
            Assert.AreEqual(expectedHeight, region.AvailableHeight, "Panel region available height should be " + expectedHeight);
        }
        public void PageWithMarginsPaddingAndFullWidthPanel()
        {
            Document doc = new Document();
            Page     pg  = new Page();

            pg.Style.PageStyle.Width  = PageWidth;
            pg.Style.PageStyle.Height = PageHeight;

            int space = 20;

            pg.Style.Padding.All = space;
            pg.Style.Margins.All = space;

            doc.Pages.Add(pg);

            //Width of fullwidth panel is reduced by margins and padding
            int expectedWidth  = PageWidth - ((2 * space) + (2 * space));
            int expectedHeight = 50;

            //Position of panel is zero - margins and padding are accounted for when rendering
            int expectedX = 0;
            int expectedY = 0;

            Panel panel = new Panel();

            panel.FullWidth   = true;
            panel.Height      = expectedHeight;
            panel.BorderColor = Scryber.Drawing.PDFColors.Black;
            pg.Contents.Add(panel);



            using (var ms = DocStreams.GetOutputStream("PanelsFullWidthWithSpacing.pdf"))
            {
                doc.LayoutComplete += Doc_LayoutComplete;
                doc.SaveAsPDF(ms);
            }

            Assert.AreEqual(1, layout.AllPages.Count, "There should be only 1 page");
            PDFLayoutPage layoutpg = layout.AllPages[0];

            //Page content block
            PDFLayoutBlock content = layoutpg.ContentBlock;

            Assert.IsTrue(content.Columns.Length == 1, "There should be only 1 column");

            //Page content region
            PDFLayoutRegion region = content.Columns[0];

            Assert.IsTrue(region.Contents.Count == 1, "There should be only one item in the region contents");

            //Panel in content
            PDFLayoutBlock panelBlock = region.Contents[0] as PDFLayoutBlock;

            Assert.IsNotNull(panelBlock, "The layout block in the page column should not be null");

            //Panel width and height
            Assert.AreEqual(expectedWidth, panelBlock.Width, "Panel block should be " + expectedWidth + " wide");
            Assert.AreEqual(expectedHeight, panelBlock.Height, "Panel block should be " + expectedHeight + " high");

            //Panel Block Total bounds
            Assert.AreEqual(expectedWidth, panelBlock.TotalBounds.Width, "Panel block total width should be " + expectedWidth);
            Assert.AreEqual(expectedHeight, panelBlock.TotalBounds.Height, "Panel block total height should be " + expectedHeight);
            Assert.AreEqual(expectedX, panelBlock.TotalBounds.X, "Panel block total X should be " + expectedX);
            Assert.AreEqual(expectedY, panelBlock.TotalBounds.Y, "Panel block total Y should be " + expectedY);

            //Panel Block Available bounds
            Assert.AreEqual(expectedWidth, panelBlock.AvailableBounds.Width, "Panel block available width should be " + expectedWidth);
            Assert.AreEqual(expectedHeight, panelBlock.AvailableBounds.Height, "Panel block available height should be " + expectedHeight);
            Assert.AreEqual(expectedX, panelBlock.AvailableBounds.X, "Panel block available X should be " + expectedX);
            Assert.AreEqual(expectedY, panelBlock.AvailableBounds.Y, "Panel block available Y should be " + expectedY);


            //Panel inner region
            Assert.IsTrue(panelBlock.Columns.Length == 1, "There should be one region in the panel block");
            region = panelBlock.Columns[0];

            //region Total bounds
            Assert.AreEqual(expectedWidth, region.TotalBounds.Width, "Panel region total width should be " + expectedWidth);
            Assert.AreEqual(expectedHeight, region.TotalBounds.Height, "Panel region total height should be " + expectedHeight);
            Assert.AreEqual(0, region.TotalBounds.X, "Panel region total X should be 0");
            Assert.AreEqual(0, region.TotalBounds.Y, "Panel region total Y should be 0");

            //region Unused bounds
            Assert.AreEqual(expectedWidth, region.UnusedBounds.Width, "Panel region unused width should be " + expectedWidth);
            Assert.AreEqual(expectedHeight, region.UnusedBounds.Height, "Panel region unused height should be " + expectedHeight);
            Assert.AreEqual(0, region.UnusedBounds.X, "Panel region unused X should be 0");
            Assert.AreEqual(0, region.UnusedBounds.Y, "Panel region unused Y should be 0");

            //region Used Size
            Assert.AreEqual(0, region.UsedSize.Height, "Panel region used height should be 0");
            Assert.AreEqual(0, region.UsedSize.Width, "Panel region used width should be 0");

            //Region Offset and available height
            Assert.AreEqual(0, region.OffsetX, "Panel region offsetX should be 0");
            Assert.AreEqual(expectedHeight, region.AvailableHeight, "Panel region available height should be " + expectedHeight);
        }
        public void DocumentStyle_WithTitle_PageGroup_AndSection_Test()
        {
            // Blank title page, followed by 2 pages with lower roman, 3 pages in the page group,
            // then inner section of lower alpha and back to a page group single page.

            string[] pgNums = new string[] { "", "i", "ii", "1", "2", "3", "e", "f", "g", "4" };

            //set up the styles

            Document doc = new Document();

            //catch all style will be applied to the document
            StyleDefn catchall = new StyleDefn();

            catchall.PageStyle.NumberStyle = PageNumberStyle.LowercaseRoman;
            catchall.AppliedType           = typeof(Document);
            doc.Styles.Add(catchall);

            //style for the page group
            StyleDefn pgGrpStyle = new StyleDefn();

            pgGrpStyle.AppliedType           = typeof(PageGroup);
            pgGrpStyle.PageStyle.NumberStyle = PageNumberStyle.Decimals;
            doc.Styles.Add(pgGrpStyle);

            //style for the section
            StyleDefn sectStyle = new StyleDefn();

            sectStyle.AppliedType                = typeof(Section);
            sectStyle.PageStyle.NumberStyle      = PageNumberStyle.LowercaseLetters;
            sectStyle.PageStyle.NumberStartIndex = 5;
            doc.Styles.Add(sectStyle);

            //build the document pages to match

            //empty title page

            Page title = new Page();

            title.Style.PageStyle.NumberStyle = PageNumberStyle.None;
            doc.Pages.Add(title);

            // 2 lower roman from the document style

            Page pi = new Page();

            doc.Pages.Add(pi);

            Page pii = new Page();

            doc.Pages.Add(pii);

            //page group with 3 pages of decimals

            PageGroup grp = new PageGroup();

            doc.Pages.Add(grp);

            Page pg1 = new Page();

            grp.Pages.Add(pg1);

            Page pg2 = new Page();

            grp.Pages.Add(pg2);

            Page pg3 = new Page();

            grp.Pages.Add(pg3);

            // section of lower alpha with 3 pages of content

            Section sect = new Section();

            grp.Pages.Add(sect);
            sect.Contents.Add(new PageBreak());
            sect.Contents.Add(new PageBreak());

            // final page in the group
            Page pg4 = new Page();

            grp.Pages.Add(pg4);



            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
            {
                doc.LayoutComplete += Doc_LayoutCompleted;
                doc.SaveAsPDF(ms);
            }

            Assert.AreEqual(layout.AllPages.Count, pgNums.Length);

            for (int i = 0; i < pgNums.Length; i++)
            {
                PDFLayoutPage lpg = layout.AllPages[i];

                string expected = pgNums[i];
                string actual   = lpg.GetPageNumber().ToString();

                Assert.AreEqual(expected, actual);
                TestContext.WriteLine("Expected '{0}', Actual '{1}'", expected, actual);
            }
        }