Print Page | Close Window

Table with many rows - many pages

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1166
Printed Date: 04 Apr 26 at 10:24AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Table with many rows - many pages
Posted By: Slawek
Subject: Table with many rows - many pages
Date Posted: 05 Aug 09 at 8:19AM
Hi

I have table with 1000 rows
TabId:= CreateTable(1000, 5);
SetTableRowHeight(TabId, 1, 1000, 0);
...

I need draw table on many pages so I do something like this:

aPageCount := 0;
 repeat
   DrawTableRows(TabId, 0.2, PageHeight - 0.2, PageHeight - 0.4, aPageCount + 1, FPDFApp.GetTableLastDrawnRow(TabId));
   aRowPage := GetTableLastDrawnRow(TabId); //aRowPage = 50
   Inc(aPageCount,aRowPage);
   if aPageCount < 1000 then
     SelectPage(NewPage);
   until aPageCount >= 1000;

But it isn't working, I have many pages but table is only on first page with first 50 rows.
How I can draw table on next page?



Replies:
Posted By: Ingo
Date Posted: 05 Aug 09 at 9:33AM
Hi!
I don't see that "NewPage" is served?
SelectPage(aPageCount) should work.
If you want to create 1000 pages with a table and your document doesn't have these 1000 pages then you have to create them ... in this case have a look at "NewPage".
What you can do, too is creating the table one time and copy this single page on the other pages. Have a look in the page management functions of QuickPDF.

Cheers, Ingo



Posted By: Slawek
Date Posted: 05 Aug 09 at 12:24PM
I want print 1000 rows on X pages. On one page I can print about 50 rows (sometimes 40 or 60, GetTableLastDrawnRow result).

I create new page and select it here:

if aPageCount < 1000 then
     SelectPage(NewPage);

aPageCount  - it's total row count from first page to current:

page - aPageCount
1 - 50 rows (from 1 to 50)
2 - 100 (from 51 to 100)
3 - 150 (from 101 to 150)
...
when aPageCount >=1000 I finish.
After that I have 20 pages but only first have table, other are clear.

I think when I do
DrawTableRows(TabId, 0.2, PageHeight - 0.2, PageHeight - 0.4, aPageCount + 1, GetTableLastDrawnRow(TabId));

table is draw on currently selected page. Is this true?




Posted By: Ingo
Date Posted: 05 Aug 09 at 9:31PM
Hi!

What's the returning value from "SelectPage(NewPage);"... error or okay?
In your loop you can try something like:
// ...
QP.NewPage;
QP.SelectPage(aPageCount);
// ... now your table
// ...

Cheers, Ingo



Posted By: Slawek
Date Posted: 06 Aug 09 at 6:22AM
>QP.NewPage;
>QP.SelectPage(aPageCount);
>

I don't do aPageCount := QP.NewPage
aPageCount - isn't a new page id, it should be aPrintedRecordCount, it's total row count from first page to current

SelectPage it's ok

I know what it's wrong: GetTableLastDrawnRow returns last printed row, not rowcount from last page.

It should be:
DrawTableRows(aTableId, 0.2, PageHeight - 0.2, PageHeight - 0.4, aPrintedRecordCount + 1, 0);
aPrintedRecordCount := GetTableLastDrawnRow(aTableId); //not Inc(aPrintedRecordCount ,GetTableLastDrawnRow(aTableId));
...

Thank you very much for help.





Posted By: Michel_K17
Date Posted: 06 Aug 09 at 3:31PM
Great job Slawek! Thanks for posting an update.

-------------
Michel



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk