Paging Document

Paging Document

Forum member · Sep 10, 2007
Hello, I'm going to buy your component and have some problems to create dinamically a PDF containing several tables. The dimension of every table is unknown so that I could obtain a document containing one or more tables in every pages. If a table cannot be fitted in a page I have to display it in a new page with the header defined. Every header contains a group area So I have to obtain something like this: ------------------------------------ Header 1 ------------------------------------ column-1 column-2 .... column-n column-1 column-2 .... column-n column-1 column-2 .... column-n ------------------------------------ Header 2 ------------------------------------ column-1 column-2 .... column-n column-1 column-2 .... column-n column-1 column-2 .... column-n column-1 column-2 .... column-n column-1 column-2 .... column-n column-1 column-2 .... column-n Next page... ------------------------------------ Header 2 ------------------------------------ column-1 column-2 .... column-n column-1 column-2 .... column-n column-1 column-2 .... column-n ------------------------------------ Header 3 ------------------------------------ column-1 column-2 .... column-n column-1 column-2 .... column-n column-1 column-2 .... column-n column-1 column-2 .... column-n column-1 column-2 .... column-n Perhaps, I don't understand how the table object works... Please, could you give me any suggestions about? Thanks

Re: Paging Document

Support · Sep 10, 2007
Hello, Yes, you can add the tables to the PDF as shown above without any problem. You can refer to the Table Class topic on our help documentation. You can add headers and rows to the table. You can get the records which does not fit in the given dimensions of the table using the GetOverflowRows method of the table object and you can add this overflow records to a new page without any problem. In order to display the headers again in the second page you will have to set the RepeatColumnHeaderCount to 1 and it will display the first row in all the overflow tables. You can refer to the Table Continuation topic on our help documentation. Thanks, ceTe Software Support Team.

Re: Paging Document

Forum member · Sep 10, 2007
Hello, first of all thanks for your prompt reply. I copied and customized the examples found in Table Continuation topic. I have to produce a document in which every page can contains more than one table. In my example, I tried to display two tables: the second one larger than the first one But the second table is not completely visible. What I'm doing wrong? How do I set table's dimensions dinamically is not so clear for me... Dim mydocument As Document = New Document Dim MyTable As Table Dim MyTable1 As Table Dim MyRow As Row Dim MyPage As Page Dim I As Integer Dim saveTableHeight As Single '----------- First Table ---------------- MyTable = New Table(0, 0, 200, 700) MyTable.RepeatColumnHeaderCount = 1 MyTable.Columns.Add(100) MyTable.Columns.Add(100) ' This loop populates the table MyRow = MyTable.Rows.Add(20) MyRow.Cells.Add("Columns 1") MyRow.Cells.Add("Columns 2") For I = 1 To 5 MyRow = MyTable.Rows.Add(20) MyRow.Cells.Add("Row #" & I) MyRow.Cells.Add("Item") Next ' This loop outputs the table to as many pages as is required MyPage = New Page saveTableHeight = MyTable.GetVisibleHeight Do mydocument.Pages.Add(MyPage) MyPage.Elements.Add(MyTable) MyTable = MyTable.GetOverflowRows() Loop While Not (MyTable Is Nothing) '----------- Second Table ---------------- MyTable1 = New Table(0, saveTableHeight + 10, 200, 700) MyTable1.RepeatColumnHeaderCount = 1 MyTable1.Columns.Add(100) MyTable1.Columns.Add(100) ' This loop populates the table MyRow = MyTable1.Rows.Add(20) MyRow.Cells.Add("Columns 3") MyRow.Cells.Add("Columns 4") For I = 1 To 50 MyRow = MyTable1.Rows.Add(20) MyRow.Cells.Add("Row #" & I) MyRow.Cells.Add("Item") Next ' This loop outputs the table to as many pages as is required Do MyPage.Elements.Add(MyTable1) MyTable1 = MyTable1.GetOverflowRows() If Not MyTable1 Is Nothing Then MyPage = New Page mydocument.Pages.Add(MyPage) End If Loop While Not (MyTable Is Nothing) ' Save the PDF mydocument.DrawToWeb(True, "MyDocument.pdf", False) Thanks for your help, Davide

Re: Paging Document

Support · Sep 10, 2007
Hello Davide, You can set or change the tables dimensions in runtime by using the Height and Width properties of the table. You can change the X, Y coordinates by using the X, Y properties of the table. When you are adding more number of tables in a page then you will have to check the height available in the page before adding a table to the page. If you have less place in the page than the table's height then you can not see the full table in that page. You will have to reset the height of the table to the height available in the page. Thanks, ceTe Software Support Team.

Re: Paging Document

Forum member · Oct 25, 2007
Are using the GetOverflowRows to paginate a table that spans across multiple pages. Am also adding a separate table that has about the same number of rows as the first table. Using the GetOverflowRows method, the second table starts on a new page. However, I would like the second table to start on the space available on the page that contains the last rows of the first table. Is there a way to do this? Thanks.

Re: Paging Document

Support · Oct 25, 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. Thanks, ceTe Software Support Team

Re: Paging Document

Forum member · Oct 25, 2007
Team, Thanks for the really quick response. Any chance you could give me an example of the solution you propose? Thanks.

Re: Paging Document

Forum member · Oct 25, 2007
Support Team, I've implemented part one of your proposed solution, but in regards to the second part, I've been unable to determine a method of accessing the last page of a document then using the addtabletopage method to begin writing a new table to that page somewhere other than the beginning of the page (using the GetRequiredHeight number + padding from this same page after the first table completed its output). Will you give me an example of how this is done? Thanks.

Re: Paging Document

Support · Oct 25, 2007
Typically, as the document is being built, you will be adding pages and as pages are added you then have a variable containing a page object of the past page in the document. If for some reason however you didn't have the last page and wanted to access it explicitly you could just reference any page from the Document's Page collection property while indexing it with the Document's Page collection's Count. In other words: Page lastPage = document.Pages[document.Pages.Count - 1]; should return the last page in the document. Every page element (including table) that you add to a page will have an associated X and Y coordinates that specify where that element is to appear on the page. If you need a table to start in the middle of a page instead of at the top of a page then you will want to adjust the Y coordinate. Thanks, ceTe Software Support Team

Re: Paging Document

Forum member · Oct 26, 2007
Team, I'm adding the second table to the existing document as follows: Dim myPage As Page myPage = New Page(PageSize.Letter, PageOrientation.Landscape) MyPage.Elements.Add(MyTable) MyDocument.Pages.Add(myPage) Which adds MyTable on a new page after the last existing page of MyDocument. As per your suggestion, I can access the last page of MyDocument, but I'm not finding any method I can use where I can add MyTable to that page, starting at some specific y coordinate. Would you give me an example of this? Thanks.

Re: Paging Document

Support · Oct 26, 2007
Hello, You can specify the Y coordinate in the constructor of the Table page element. If you are adding the overflow Table then, use the overloaded GetOverflowRows method that takes X and Y coordinate. Following is the sample code block: Do Dim MyPage As Page = New Page MyDocument.Pages.Add(MyPage) MyPage.Elements.Add(MyTable) MyTable = MyTable.GetOverflowRows(50, 50) Loop While Not (MyTable Is Nothing) Thanks, ceTe Software Support Team

Re: Paging Document

Forum member · Oct 26, 2007
I've got something working now. Thanks for the quick responses and for steering me in the right direction.