Bulletlist in a column causing overflow

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v11)  /  Bulletlist in a column causing overflow

DynamicPDF CoreSuite for .NET (v11) Forum

I am using a Table2 class to output data to a PDF. In one of the columns I am using a Bulletlist. The items in the Bulletlist are dynamic and can become large enough to go beyond the page height. What is the best way to handle this?

Posted by a ceTe Software moderator

Are you using the Orderedlist/UnorderedList page element to add data to a cell of table? If so, then the cell to which you are adding the page element will not be auto splitable. You will need to handle overflow list and add it to a new row accordingly. Once a Table2 is completely built then add it to page in a loop by setting correct height.

If you continue facing an issue, then please send over following information to support@dynamicpdf.com so we can look into it further.

1. Simple console application or code sample which uses static data to recreate the behavior.
2. Output PDF.
3. Exact version and build number of the DynamicPDF DLL file used in your application. You can find this information by right clicking on the DLL file>>Properties>>Details tab>>Product version. Take a screenshot of Details tab and send it over to us.

ceTe Software Support Team
Yes, I am using an UnorderedList. Are there any examples available of the solution you mentioned?

Also, what option would I use to make it auto splittable?

Posted by a ceTe Software moderator

There is no option to make the cell auto splitable when a page element is added to it. You will need to handle the overflow and splitting dynamically.

Here is a code sample to add an UnorderedList to PDF using Table2 object by handling overflow.

           // Create a UnorderedList.
            UnorderedList list = new UnorderedList(0, 0, 300, 500);

            list.ListItemTopMargin = 5;
            list.ListItemBottomMargin = 5;
            list.TextColor = RgbColor.BlueViolet;

            // Add ListItem to the List.
            ListItem item1 = list.Items.Add("List item 1");
            item1.Underline = true;
            ListItem item2 = list.Items.Add("List item 2");
            item2.Underline = true;
            ListItem item3 = list.Items.Add("List item 3");
            item3.Underline = true;
            ListItem item4 = list.Items.Add("List item 4");
            item4.Underline = true;

            // Add UnorderedSubList under ListItem item1
            UnorderedSubList subList1 = item1.SubLists.AddUnorderedSubList(UnorderedListStyle.Circle);
            subList1.TextColor = RgbColor.HotPink;
            ListItem item5 = subList1.Items.Add("Sub-list item 1");
            ListItem item6 = subList1.Items.Add("Sub-list item 2");

            UnorderedSubList subList2 = item5.SubLists.AddUnorderedSubList(UnorderedListStyle.Square);
            subList2.TextColor = RgbColor.DarkGoldenRod;
            ListItem item7 = subList2.Items.Add("Second level sub-list item 1");
            ListItem item8 = subList2.Items.Add("Second level sub-list item 2");

            UnorderedSubList subList3 = item6.SubLists.AddUnorderedSubList(UnorderedListStyle.Square);
            subList3.TextColor = RgbColor.DarkGoldenRod;
            ListItem item9 = subList3.Items.Add("Second level sub-list item 1");
            ListItem item10 = subList3.Items.Add("Second level sub-list item 2");

            UnorderedSubList subList4 = item2.SubLists.AddUnorderedSubList(UnorderedListStyle.Circle);
            subList4.TextColor = RgbColor.HotPink;
            ListItem item11 = subList4.Items.Add("Sub-list item 1");
            ListItem item12 = subList4.Items.Add("Sub-list item 2");

            UnorderedSubList subList5 = item11.SubLists.AddUnorderedSubList(UnorderedListStyle.Square);
            subList5.TextColor = RgbColor.DarkGoldenRod;
            ListItem item13 = subList5.Items.Add("Second level sub-list item 1");
            ListItem item14 = subList5.Items.Add("Second level sub-list item 2");

            UnorderedSubList subList6 = item12.SubLists.AddUnorderedSubList(UnorderedListStyle.Square);
            subList6.TextColor = RgbColor.DarkGoldenRod;
            ListItem item15 = subList6.Items.Add("Second level sub-list item 1");
            ListItem item16 = subList6.Items.Add("Second level sub-list item 2");

            UnorderedSubList subList7 = item3.SubLists.AddUnorderedSubList(UnorderedListStyle.Circle);
            subList7.TextColor = RgbColor.HotPink;
            ListItem item17 = subList7.Items.Add("Sub-list item 1");
            ListItem item18 = subList7.Items.Add("Sub-list item 2");

            for (int i = 1; i < 25; i++)
                UnorderedSubList subListobj = item4.SubLists.AddUnorderedSubList(UnorderedListStyle.Circle);
                subListobj.TextColor = RgbColor.BlueViolet;
                ListItem itemObj1 = subListobj.Items.Add("Sub-list item " + (i));


            Document document = new Document();
            Table2 table = new Table2(0, 0, 300, 0);
            // Add columns to the table
            Page page1 = new Page();
            float occupiedHeight = table.Y;

            // Build the table by adding the UnOrderedList to cell.
            Row2 row = table.Rows.Add(20);
            if (list.GetRequiredHeight() < page1.Dimensions.Body.Height - occupiedHeight)
                list.Height = list.GetRequiredHeight();
                list.Height = page1.Dimensions.Body.Height - occupiedHeight;
            Cell2 cell2 = row.Cells.Add(list);
            row.Height = list.Height;
            list = list.GetOverFlowList();
            while (list != null)
                Row2 newRow = table.Rows.Add();
                list.Height = list.GetRequiredHeight();
                if (list.GetRequiredHeight() < page1.Dimensions.Body.Height)
                    list.Height = list.GetRequiredHeight();
                    list.Height = page1.Dimensions.Body.Height;
                Cell2 newcell2 = newRow.Cells.Add(list);
                newRow.Height = list.Height;
                list = list.GetOverFlowList();

            //Adding table to the PDF page.
                Page page = new Page();
                if (table.GetRequiredHeight() < page.Dimensions.Body.Height)
                    table.Height = table.GetRequiredHeight();
                    table.Height = page.Dimensions.Body.Height;
                table = table.GetOverflowRows();
            } while (table != null);

            // Save the PDF

ceTe Software Support Team

All times are US Eastern Standard time. The time now is 5:34 AM.