Forum How do I...?

Table heights

OliverFoggin
Hi All,

First time post here. Hope someone can help.

I am trying to format a document which has a load of repeating info in the page header and the main body of the document is a table.

The table may contain 3 or 4 lines or may conatin 3 or 4 hundred lines.

At the moment I have it successfully breaking over the page break but I would like the border of the table (and I have one vertical column border e.g. |Item Description Qty | Price |) to continue down to the end of the page. At the moment the table border stops directly below the last row of the table on that page and then the table continues on the next page.

I have tried setting the height (percentage and cm) of the table but this doesn't work. I've tried altering the div that the table is in. I'm not sure what else to try now?

Please could you provide a pointer of what I should be looking at.

Thanks

Oliver
OliverFoggin
OK, taking an example from another thread...

This is what is happening...
|---------------------|
|Item    Qty  |  Price|
|---------------------|
|ABC      12  |    100|
|DEF       1  |     30|
|GHI      20  |    130|
|---------------------|



<---- Page Break ---->
|---------------------|
|Item    Qty  |  Price|
|---------------------|
|JKL       2  |    100|
|MNO       1  |     30|
|PQR     100  |    130|
|---------------------|





And this is what I want to happen...
|---------------------|
|Item    Qty  |  Price|
|---------------------|
|ABC      12  |    100|
|DEF       1  |     30|
|GHI      20  |    130|
|             |       |
|             |       |
|             |       |
|---------------------|
<---- Page Break ---->
|---------------------|
|Item    Qty  |  Price|
|---------------------|
|JKL       2  |    100|
|MNO       1  |     30|
|PQR     100  |    130|
|             |       |
|             |       |
|             |       |
|---------------------|


I hope that makes a bit more sense.

Thanks again
mikeday
This is a tricky issue, and right now I'm not sure how to do this. In theory it should be a matter of specifying a fixed height on the table (and potentially its containing elements), however at present this will interfere with page breaking, with unintended consequences. We hope to fix this bug in a future release of Prince. Another option is adding a border to the whole page using an @page rule, but this may not be quite what you want.
OliverFoggin
Thanks for the reply.

I think what we may end up doing is removing the border from the table completely and use a div in the header of the document positioned absolutely around the table with a borde on the div.

I'll keep an eye out for future updates.

Thanks

Oliver
gilbeyjon
Hi

Just like Oliver, I have a similar problem where I have a table that I need to be 100% so that the last row has empty space down to the page footer.

If I create the html page outside of princexml and remove the doctype declaration it works fine - quirks mode I guess.

I understand that table height has been deprecated and only works in quirks mode - but this isn't available in princexml.

Obviously any page-breaking needs to be respected too.

Is there anything else I could consider doing to achieve my objective?

Many Thanks
Jon
mikeday
So if you specify a height for the table, or for the last row, what exactly is wrong with the layout?
gilbeyjon
Hi Mike
The height of the table is not respected, here's an example:
(in a browser it doesn't display properly either, but if I take out the doctype it's fine).

<!doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<table style="border: 1px solid red; height:100%;width: 200px;">
<tr>
   <td valign="top">1</td>
</tr>
<tr>
   <td valign="top">2</td>
</tr>
<tr>
   <td valign="top">3</td>
</tr>
<tr>
   <td valign="top">Last Row</td>
</tr>
</table>

<table style="border: 1px solid green; width: 200px;">
<tr>
   <td valign="top">Footer</td>
</tr>
<tr>
   <td valign="top"></td>
</tr>
<tr>
   <td valign="top"></td>
</tr>
<tr>
   <td valign="top"></td>
</tr>
</table>
</body>
</html>


Edited by mikeday

mikeday
Percentage heights will be respected if the ancestors of the element also have a fixed height. For example, by doing this:
html, body { height: 100% }

However, this can produce awkward results in Prince, as it restricts the height of the root element to the height of the page, which is fixed (unlike in the browser, where the window can scroll and grow taller).

I would suggest giving the table an absolute height, eg. use inches or centimetres.
gilbeyjon
Hi Mike,

I've just realised that I'd forgotten to say that after the table there is a footer (green table) of variable length, so fixing the top table (red table) length wouldn't work.

Sorry about that.

Jon

mikeday
Okay, this is getting more complicated. :)

What about putting the footer inside the <tfoot> of the first table?
nitinpatil
hi mike i also facing same issue (same as OliverFoggin )..... i want dynamic height for table