getOverFlowRows

getOverFlowRows

Forum member · Oct 9, 2007
Hi, I have created a PDF with many different tables that all run together. As my code runs, I test to see when a table will overflow using a public variable. When the table does overflow I reset the table height to attempt to force an overflow. I run a do while loop - add a new page, add the table name and call GetOverFlowRows. Unfortunately this is not working. My code looks like this: tableName.Height = tableName.GetRequiredHeight - overFlow Do SubmitPage = New ceTe.DynamicPDF.Page SubmitPage.Dimensions.LeftMargin = 27 SubmitPage.Dimensions.RightMargin = 27 SubmitDocument.Pages.Add(SubmitPage) height = 0 tableName.Y = 0 SubmitPage.Elements.Add(tableName) height = height + tableName.GetRequiredHeight tableName = tableName.GetOverflowRows() Loop While Not (tableName Is Nothing) Anyone out there have any ideas? Thanks in advance!

Re: getOverFlowRows

Support · Oct 9, 2007
Hello, Can you please tell us what exact problem are you experiencing in detail when you tell its not working? Are you getting any errors or does the table overflow not work correctly? Thanks, ceTe Software Support Team

Re: getOverFlowRows

Forum member · Oct 9, 2007
Sorry - the problem is that getOverFlowRows only returns a null - and I'm never actually able to overflow the table to my new page. Even though my table height variable is smaller than the amount of data in the table. Private Sub NewPage(ByVal tableName As Table, ByVal split As Integer) height = height + tableName.GetRequiredHeight If split = 0 Then If height > 670 Then 'needs to overflow the entire section (no split) Dim x As Integer = 0 x = x + 1 SubmitPage = New ceTe.DynamicPDF.Page SubmitPage.Dimensions.LeftMargin = 27 SubmitPage.Dimensions.RightMargin = 27 SubmitDocument.Pages.Add(SubmitPage) SubmitPage.Elements.Add(tableName) height = 0 tableName.Y = 0 height = height + tableName.GetRequiredHeight Else SubmitPage.Elements.Add(tableName) End If ElseIf split = 1 Then 'needs to overflow the part of the section (split the table) If height > 670 Then 'calculate the overflow amount and set new table height to force overflow Dim overFlow As Single overFlow = height - 670 ' gets desired overflow amount 'sets the new table height to be smaller than the desired data (to force overflow) tableName.Height = tableName.GetRequiredHeight - overFlow Do SubmitPage = New ceTe.DynamicPDF.Page SubmitPage.Dimensions.LeftMargin = 27 SubmitPage.Dimensions.RightMargin = 27 SubmitDocument.Pages.Add(SubmitPage) height = 0 tableName.Y = 0 SubmitPage.Elements.Add(tableName) height = height + tableName.GetRequiredHeight tableName = tableName.GetOverflowRows() Loop While Not (tableName Is Nothing) Dim x As Integer = 0 x = x + 1 Else SubmitPage.Elements.Add(tableName) End If Else 'error End If end sub Hope this helps - thanks for looking

Re: getOverFlowRows

Support · Oct 9, 2007
Hello, You do not need to reset the height of the overflow table because tableName.Height will change the height of the main table since you are using the same variable name for both; main table and the overflow table. The following sample code will accomplish the task for you: Do Dim SubmitPage As Page = New Page SubmitPage.Dimensions.LeftMargin = 27 SubmitPage.Dimensions.RightMargin = 27 MyDocument.Pages.Add(SubmitPage) SubmitPage.Elements.Add(MyTable) MyTable = MyTable.GetOverflowRows() Loop While Not (MyTable Is Nothing) Thanks, ceTe Software Support Team

Re: getOverFlowRows

Forum member · Oct 9, 2007
Thanks again for your help, Unfortunately I have been unclear in what I am saying. I really don't have a main table - I have around 10 distinct tables that I am passing to the new page sub. It builds each table in order and determines if the added table should go on a new page or on the existing page. For the larger tables in my document - I would like to split them so that a header and the overflow goes to the new page. When I reference "tableName" I am using it as a variable that is being passed into the sub. What I was trying to do was to define a new height for the table that was passed in to cause it to overflow. I would then send it all of the data I wanted in it. When I called the overflow method it would see that the height of the table was insufficient to hold all of the data and overflow. What happens is the whole table simply goes to the new page. Sorry for any confusion I've caused.

Re: getOverFlowRows

Support · Oct 9, 2007
All that you mentioned in your previous post seems to be pretty straight forward and is not a problem to do using some of the built in functionality of the Table object. First, I won’t try and dissect your code to determine what you are doing right and what's going wrong. Frankly, there is a lot of logic in there that I am not sure if it is necessary. What I will attempt to do however is give you a good overall description of the likely flow that your logic will want to take. Then I can leave the implementation of that code up to you. The idea to keep in mind is that you will need to keep dynamic track of the current Y location of the page. Answering these questions will get you exact placement of any elements as they flow from page to page: Where will your dynamic table start? How much room is left on the page? How much space was required to fit your dynamic table? Was there any overflow? 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. You mentioned that when a table flows from one page to another you wanted the table header column to be repeated and that can be done by setting the Table's RepeatColumnHeaders to true. Follow this logic looping over each of your tables. That should be all the logic you need to implement a clean solution. Thanks, ceTe Software Support Team

Re: getOverFlowRows

Forum member · Oct 10, 2007
Thanks again for your help, In the end my problem was that I was building my solution as tables within tables. When I passed a table to getoverflowrows() that had only a couple of rows, each row containing a different table the function would assume that no overflow was needed. Even though my combined table was large - it still only looked like a couple of rows to the function. The rows were also different sizes. I'm not sure what the function is internally doing however - I now know that I have to break my tables out differently than I am now currently doing. Thanks again for all your help!