Responsive PDF Document

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v12)  /  Re: Responsive PDF Document

DynamicPDF CoreSuite for .NET (v12) Forum

 Mar 25 2025 2:14 PM
I'm creating a PDF document consisting of a number of Labels, TextArea's and one Table2.  The placement of the Page Elements are all done using x, y coordinates values.

The issue is the Table is dynamic and can have n-number of rows displayed which isn't determined until "run-time" of the application.   If I place Elements below the Table, there's a chance the Elements will be overwritten by the Table rows.

One thought came to mind is have the table as last Element on the document. Is there a way to have the Elements below the Table adjust their position?
 Mar 26 2025 5:47 AM
Posted by a ceTe Software moderator - Commonly asked question
Hi,

Yes. you can add TextArea, Label page elements below dynamic table without any problem using our DynamicPDF Core Suite for .NET product. You will need to calculate Y position and  get the last page and table height and use these values to add elements after table laying is completed.

Here is a code sample.

            float tabelht = 0;
            float tableYPosition = 0;
            Table2 table = new Table2(0, 0, 200, 692);
            table.Columns.Add(100);
            table.Columns.Add(100);

            for(int i=1;i<100;i++)
            {
                Row2 row1= table.Rows.Add();
                row1.Cells.Add("Columns1: Text" + i);
                row1.Cells.Add("Columns2: Text" + i);

            }
            //Add table to document.
            Document document = new Document();
            do
            {
                Page page = new Page();
                document.Pages.Add(page);
                tableYPosition = table.Y;
                page.Elements.Add(table);
                tabelht = table.GetRequiredHeight();
                table = table.GetOverflowRows();
            } while (table != null);

            int currentPageNumber = document.Pages.Count -1;
            Page currentPage = document.Pages[currentPageNumber];
            //Adding new TextArea below Table.
            float YPosition = tableYPosition + tabelht + 10;
            TextArea area = new TextArea("New Text below dynamic Table", 0, YPosition, 100, 40);
            currentPage.Elements.Add(area);
            string outputPdf = @"C:\Temp\MyTable.pdf";
            document.Draw(outputPdf);

Thanks,
ceTe Software Support Team
           


All times are US Eastern Standard time. The time now is 8:23 AM.