Table continuation

Table continuation

Forum member · Nov 8, 2007
ceTe; I have a document that consists of two tables of unknown length. I need the second table to always start immediately after the end of the first table (with some blank spacing between). The first table may span one or more pages, and the second table can span one or more pages. How can get the second table to start on the same page as the first table ends, and still continue correctly if it needs to span several pages? Do you have an example of nested tables spanning several pages each? Thanks,

Re: Table continuation

Support · Nov 9, 2007
Hello, You can do this using the GetRequiredHeight() method of the Table. First you will have to add the Table to your page. Then you will have to keep track of the Y co-ordinate and start the second Table from the point where the first Table ends. One way to do this is by finding out the Height used by the table or the overflow table (if it overflows on page two) using the GetRequiredHeight() method of the first table. Then use that value plus some padding as the starting Y co-ordinate for your second Table. I will go through how I would imagine your logic to flow for the first table. From there the logic should just repeat. Let’s say you want to start your first table on the page underneath some page level header type information. So the first table lets give it a Y location of 75. In this case we will just assume the X location to be zero for all the tables to line up vertically. Assuming a standard 8.5 x 11 inch page (612 x 792 points) with default 50 point margins and a starting Y location of 75 you would have 617 points until you reach the bottom useable page area (792 height - 50 top margin - 50 bottom margin - 75 offset Y location = 617). So taking your first table you should first check the GetRequiredHeight method. If the value returned from the GetRequiredHeight method of your first table is less than 617 (or whatever that value you ended up with from above) then you know that table will fit on that page. You could then recalculate the remaining height for the page (617 minus the GetRequiredHeight from the table before). Then that new value will be the value that you will compare against the GetRequiredHeight from the next table. And the new starting y value will just be the last starting Y value plus the GetRequiredHeight for the last table. At some point the GetRequiredHeight for a table will end up being larger than the remaining height left on the page. When that happens you would just set the Height property of the current Table (the one you are trying to fit on the bottom of the page) to the remaining height on that page. Then you know you need to create another Page in your document (remember to now reset the variable keeping track of the current Y location and the variable keeping track of the remaining height on the page). Then you will call the GetOverflowRows method that will return a new table containing all the rows that didn’t fit on the first page. Now continue as you did above to check the GetRequiredHeight on the Table returned by the GetOverflowRows method. You can see that this would just continue until the entire table is output regardless of the number of pages required. Thanks, ceTe Software Support Team

Re: Table continuation

Forum member · Nov 9, 2007
ceTe, Seems clear enough, I'll give it a shot. Thank you!

Re: Table continuation

Forum member · Nov 12, 2007
ceTe, Works great. Thanks for the help.