Project

General

Profile

How to know PageNo in table construction

Added by Philippe P over 9 years ago

Hi,
I display a table and i need to know row number related to each page to display it in the table cell.
For example, page 1:
row 1
row 2
row 3
...
The page 2
row 1
row 2
row 3
...
And so on...

So , to reinitialise the row counter on each page, i need to know if the page has changed.
I tried the oPdf->PageNo() function but is not effective until the pdf->output.

Is there a way to know it while the table construction ?

Thank you
Best Regards

Best regards


Replies (5)

RE: How to know PageNo in table construction - Added by Andrei Bintintan over 9 years ago

It's a tricky question, due to the rowspan of the rows it's difficult to calculate and the paging is not calculated until the $table->close() is called.
All I can say is that out of the box it's not supported, but I'll think on a solution.

RE: How to know PageNo in table construction - Added by Philippe P over 9 years ago

OK. Thank you for quick answer.

I tried to manage it in different way.

One last question : how to add a cover page before display the table ?

Thank you

RE: How to know PageNo in table construction - Added by Andrei Bintintan over 9 years ago

Philippe P wrote:

One last question : how to add a cover page before display the table ?

The most easy way is to do it in the Header function. This way you do not need to change the table class.

An with this a next feature idea: a sort of beforeAddPage, afterAddPage hooks.

RE: How to know PageNo in table construction - Added by Philippe P over 9 years ago

Thank your for quick answer.

Finally, i've resolved my problems.

1/ the row number related to each page
It's little tricky : it needs to generate two pdf and use an ocr utility:
a) The first pdf generates for each row an incremental row number for all rows. And of course on each page a page number is generated in the footer.
b) By using the php exec function, it's possible to launch the command line utitity pdftoextract (downloaded from xpdf free utility) to create an ocr text file from the first pdf .
Read this text file to identify rows numbers and identify footer page number, and fill an array like this: arr_row_number[indentified row_number]=identified page number.
c) Generate the final pdf and this time, for each row number, calculate the related row number from soustraction of first row number in each page found in arr_row_number array.

2/ Cover page

In fact, the header doesn't repeat on each page... it appears only on the first page. I don't know why . But for this project , it's not a matter.
So, adding $opdf->addpage() before the "$oTable = new pdfTable..." creates the cover page with the header only and the table appears on the next page.
So, it's Ok !

Best regards

RE: How to know PageNo in table construction - Added by Andrei Bintintan over 9 years ago

Hi Philippe,

Good that you have found solutions.
Thank you for your feedback. I will also investigate a bit, these are features that could be helpful in the future.

Andrei.

    (1-5/5)