XSL - HTML table footer displaying dynamically in position ( changing as per the number of rows in a table ) - html

I have a XSL sheet embedded with HTML tags, from which I generate a PDF using Java. I'm able to generate the PDF using this XSL stylesheet.
In my XSL i have a model like :
Page 1:
Header
Table
row 1
row 2
row 3
row 4
row 5
Footer
Page 2:
Header
Table
row 6
row 7
row 8
row 9
row 10
Footer
Page 3:
Header
Table
row 11
row 12
row 13
Footer
I should have show table rows 5 per page with Header and Footer. The problem is, I have to show the footer as a static content irrespective of the number of rows in the table.
for example: if the table contains 5 rows or 4 or 3 or 2 or 1, the footer should be at the bottom of the page. Instead, it is displaying dynamically under the table, as the table size changes.
Please find my XSL Stylesheet code below :
<xsl:copy-of select="$Header"/>
<xsl:copy-of select="$OrderRowsHeader"/>
<xsl:for-each select="orders">
<table style=" width: 100%; height: 13mm;">
<tr style="font-size: 10px; border: 0">
<td width="14mm" style="text-align: right; vertical-align: top;"><xsl:value-of select="number" /></td>
<td width="36mm" style=" text-align: left; vertical-align: top;"><xsl:value-of select="code" /></td>
<td width="47mm" style=" text-align: left; vertical-align: top;" ><xsl:value-of select="description" /></td>
<td width="12mm" style=" text-align: left; vertical-align: top;"><xsl:value-of select="units" /></td>
<td width="16mm" style=" text-align: right; vertical-align: top;"><xsl:value-of select="quantity" /></td>
</tr>
</table>
<xsl:if test="(position() mod 5) = 0 and ( position() != last() )">
<xsl:copy-of select="$ReportFooter" />
<div style="page-break-before: always" />
<xsl:copy-of select="$Header"/>
<xsl:copy-of select="$OrderRowsHeader"/>
</xsl:if>
</xsl:for-each>
<xsl:copy-of select="$ReportFooter" />
<xsl:variable name="ReportFooter">
<table style="border: solid thin #c0c0c0; border-collapse: collapse; width: 100%; ">
<tr style="border: solid thin #c0c0c0; border-collapse: collapse;">
<td width="150mm" style="border: solid thin #c0c0c0; border-collapse: collapse; font-size: 8px;">
</td>
Some Text here......
</tr>
</table>
</xsl:variable>
<xsl:variable name="OrderRowsHeader">
<table style="border: solid thin #c0c0c0; border-collapse: collapse; width: 100%;">
<tr style="border: solid thin #c0c0c0; font-size: 9px; border-collapse: collapse;">
<th width="18mm" style="border: solid thin #c0c0c0; border-collapse: collapse;">Line</th>
<th width="45mm" style="border: solid thin #c0c0c0; border-collapse: collapse;">Product code</th>
<th width="63mm" style="border: solid thin #c0c0c0; border-collapse: collapse;">Description</th>
<th width="18mm" style="border: solid thin #c0c0c0; border-collapse: collapse;">Units</th>
<th width="16mm" style="border: solid thin #c0c0c0; border-collapse: collapse;">Qty</th>
</tr>
</table>
</xsl:variable>

Sounds like you are running into a styling issue. Your solution is found in CSS. I won't address any of your code besides what is relevant to the footer.
<xsl:variable name="ReportFooter">
<table style="position: absolute; bottom: 0; border: solid thin #c0c0c0; border-collapse: collapse; width: 100%; ">
<tr style="border: solid thin #c0c0c0; border-collapse: collapse;">
<td width="150mm" style="border: solid thin #c0c0c0; border-collapse: collapse; font-size: 8px;">
</td>
Some Text here......
</tr>
</table>
</xsl:variable>
The properties I've added to add to the table are: position: absolute; bottom: 0;
position: absolute will have the table ignore the flow of the page (meaning it does not flow relative to other elements), and bottom is a measurement of how far it is from the bottom of the page, so bottom: 0 will put it at the bottom of the parent container.

Related

How to remove small space affecting inner <td> borders between rows [Netsuite]

I have a table where there should be a border only on certain sides of certain elements - i.e. everywhere except the bottom and left side of the td:first-child
Required Table - td:first-child no borders:
The problem: Small white spaces where borders don't come together between rows and columns (at corners)
Current result - white space:
This is the code.
table.total td {
padding-top: 5px;
padding-bottom: 5px;
line-height: 125%;
}
table.total td.totalleft {
padding-left: 15px;
border-left: 1px solid black;
border-bottom: 1px solid black;
border-right: 1px solid black;
}
table.total td.totalright {
border-right: 1px solid black;
border-bottom: 1px solid black;
}
<table class="total" style="width: 100%;">
<tr>
<td colspan="3"> </td>
<td colspan="4" class="totalleft">${record.subtotal#label}</td>
<td align="right" colspan="2" class="totalright">${record.subtotal}</td>
</tr>
<tr>
<td colspan="3"> </td>
<td colspan="4" class="totalleft">Sales Tax</td>
<td align="right" colspan="2" class="totalright">${record.taxtotal}</td>
</tr>
<tr>
<td colspan="3"> </td>
<td colspan="4" class="totalleft">Freight</td>
<td align="right" colspan="2" class="totalright">${record.shippingcost}</td>
</tr>
<tr>
<td colspan="3"> </td>
<td colspan="4" class="totalleft">Total Invoice Amount</td>
<td align="right" colspan="2" class="totalright">${record.subtotal+record.taxtotal+record.shippingcost}</td>
</tr>
</table>
Things I've tried
Adding padding: 0; margin 0; under *, table, etc in CSS
Adding border-collapse: collapse, border-spacing: 0;
As a workaround, I've even tried "moving up" into the to remove the white corner using position: relative; top: -1px. But that just creates a white gap between the bottom row/cell and the border-bottom of the entire table
Thanks for any help!

How do you make image height suit the content of the column beside it?

I have the following code
table,
th,
td {
border: 1px solid black;
border-collapse: collapse;
}
th,
td {
padding: 5px;
text-align: left;
}
img {
object-fit: cover;
}
.ninja {
font-family: Bebas Neue;
font-size: 30px;
}
<table style="width:80%">
<tr>
<th rowspan="3" width="50%">
<img style="display: block;width: 100%;height: 100%" src="image.jpg" />
</th>
<td valign="top"><strong class=n inja>WHY WONT YOU LET IT GO</strong></td>
</tr>
<tr style="height: 0;">
<td>55577855</td>
</tr>
<tr style="height: 0;">
<td>55577855</td>
</tr>
<tr>
<td>HAHAHAHA</td>
</tr>
</table>
The problem is, the text all have big spaces all the way down because their total height has to account for the image's height. How do I make it the other way around as I would be fine with the image being minimized or made smaller so the text does not have the long spaces below their content?

Width of cell ignored

I have looked for many posts but I could not find an answer that suits this problem. I have tried with table-layout:fixed, changing widths to extreme values but the attribute width is still being ignored. Here is my code:
<table style="width:100%; table-layout:fixed; border: 1pt solid black;
border-collapse: collapse;" border cellpadding=3 cellspacing=0>
<tr>
<th align=center colspan="4"
style="width:100%; color:white; background-color:#475678; font-weight:bold;">
Oferta de traducción para: ' . $cliente . '
</th>
</tr>
<tr>
<td style="border-right:1pt solid black; width:10%;">Fecha</td>
<td align=center style="border-right:1pt solid black; width:10%;">Fecha</td>
<td style="border-right:1pt solid black; width:40%;"></td>
<td style="width:30%;">Fecha</td>
</tr>
</table>
Your issue was using table-layout: fixed;
Here is my retake on it.
Within the <style> you should put this into your css but assign an id or class to it if you're using tables elsewhere that are different:
table {
width: 100%;
border:1pt solid black;
border-collapse: collapse;
}
table td {
width:25%;
border-right: 1pt solid black;
text-align: center;
}
table th {
width: 100%;
color: white;
background: #475678;
font-weight:bold;
}
<table cellpadding="3" cellspacing="0">
<tr>
<th align=center colspan="4">Oferta de traducción para: ' . $cliente . '</td>
</tr>
<tr>
<td>Fecha</td>
<td>Fecha</td>
<td></td>
<td>Fecha</td>
</tr>
</table>
If you want to keep your CSS in the actual code, just remove the table-layout from <table> styling.
the table-layout: fixed is the one that ignores your widths.
from MDN HTML table-layout says like this about the table-layout: fixed,
Table and column widths are set by the widths of table and col
elements or by the width of the first row of cells. Cells in
subsequent rows do not affect column widths.
Try remove table-layout:fixed; and it will work.

Restricted to CSS-2.1, can I ensure that one border in a table shows 'on top' of another border when borders are collapsed

Pictures are worth much more than words, in this case. See how the intersection of the top, black bar and the lightgrey, vertical bar between 'Left' and 'Right' is lightgrey instead of black? Is there a way to ensure that one border is shown 'above' another, kind of like a z-index?
How it looks:
How I want it to look (adjusted with image editor):
Here's a jsfiddle for my issue. If you don't like jsfiddle, for whatever reason, my HTML and CSS are below.
HTML:
<table id="tiresTable" class="table">
<tr class="firstRow">
<td class="thSim">Tires:</td>
<td class="thXAxis borderRight">Left</td>
<td class="thXAxis">Right</td>
</tr>
<tr class="borderBottom">
<td class="thYAxis">Front</td>
<td class="borderRight"></td>
<td></td>
</tr>
<tr class="borderBottom">
<td class="thYAxis">Rear</td>
<td class="borderRight"></td>
<td></td>
</tr>
<tr>
<td class="thYAxis">Spare</td>
<td colspan="2"></td>
</tr>
</table>
CSS:
#tiresTable{
border-collapse: collapse;
}
#tiresTable tr.firstRow td{
border-bottom: 1px solid black;
}
#tiresTable td.thSim, #tiresTable td.thYAxis{
border-right: 1px solid black;
}
#tiresTable td.borderRight{
border-right: 1px solid lightgrey;
}
#tiresTable tr.borderBottom{
border-bottom: 1px solid lightgrey;
}
Please note that, due to technological constraints, I cannot use CSS3 properties. Also note that I will not be offended if you edit my question title if you can describe the issue more eloquently than I have.
EDIT:
It was a little hacky but I was able to do something that works as you need.
HTML:
<table id="tiresTable" class="table">
<tr class="firstRow">
<td class="thSim">Tires:</td>
<td class="thXAxis borderRight">Left</td>
<td class="thXAxis">Right</td>
</tr>
<tr class="border-bottom">
<td colspan="3"><div class="black"></div></td>
</tr>
<tr class="borderBottom">
<td class="thYAxis">Front</td>
<td class="borderRight"></td>
<td></td>
</tr>
<tr class="borderBottom">
<td class="thYAxis">Rear</td>
<td class="borderRight"></td>
<td></td>
</tr>
<tr>
<td class="thYAxis">Spare</td>
<td colspan="2"></td>
</tr>
</table>
CSS:
#tiresTable{
border-collapse: collapse;
}
#tiresTable tr.borderBottom{
border-bottom: 1px solid lightgrey;
}
#tiresTable td.borderRight{
border-right: 1px solid lightgrey;
}
#tiresTable td.thSim, #tiresTable td.thYAxis{
border-right: 1px solid black;
}
.border-bottom {
height: 1px;
}
.border-bottom td {
height: 1px;
border: 0px;
padding: 0px;
}
.black {
background-color: black;
height: 1px;
}
I removed anything that is not really required, and used altered classes names to know easily what is new and what is not.
Fiddle: http://jsfiddle.net/ru92py4m/15/

CSS Table: bottom borders that don't touch and rounded corners

Here's the fiddle for what I'm working on:
http://jsfiddle.net/rSUhL/
I'm trying to replicate this image:
I'm pretty close. But for some reason, when I add border-radius to the table, it doesn't round the corners.
Also, is it possible to make it so the bottom-border doesn't touch the side of the boxes?
Here's the CSS:
table {
border-collapse: collapse;
text-align: center;
margin-left: auto;
margin-right: auto;
font-size: 18px;
}
th, td {
border: 1px solid #d8d8d8;
border-collapse: collapse;
padding: 25px;
}
th {
text-align: right;
}
#blank {
border: none;
}
caption {
margin-bottom: 15px;
}
.blue {
background-color: #2a9ce0;
color: #fff;
border-bottom: 1px solid #55ace0;
}
.small-text {
font-size: 13px;
margin-top: -5px;
}
HTML:
<table>
<caption>Is Mastermind Talks for you?</caption>
<tr>
<th scope="row">Learning:</th>
<td>Tabloids and Newspapers</td>
<td class="blue">Books, blogs, seminars and peers</td>
</tr>
<tr>
<th scope="row">Focus:</th>
<td>Hourly or Salary</td>
<td class="blue">Cashflow, net worth and network</td>
</tr>
<tr>
<th scope="row">Financial Goals:</th>
<td>To survive until the next payday</td>
<td class="blue">To build passive income streams</td>
</tr>
<tr>
<th scope="row">Rate of Return:</th>
<td>Get Rich Quick</td>
<td class="blue">Long-term</td>
</tr>
<tr>
<th scope="row">Investments:</th>
<td>Liabilities: Cars, houses, etc</td>
<td class="blue">Assets: Yourself, business, etc</td>
</tr>
<tr>
<th scope="row">Values:</th>
<td>Currency</td>
<td class="blue">Legacy</td>
</tr>
<tfoot>
<td id="blank"></td>
<td><strong>Middle Class Mindset</strong><br /> <span class="small-text">(mastermind is not for you)</span></td>
<td class="blue"><i class="icon-bulb"></i><strong>Mastermind Mindset</strong><br /> <span class="small-text">(mastermind is for you)</span></td>
</tfoot>
</table>
The border-radius declaration does not work with table border if the border-collapse is set to collapse. You have to define your borders on the td elements for border radius to work in this case.
Or, you can use border-collapse: separate; for border radius to work on the table itself.
Change the class name of
<td class="blue">Books, blogs, seminars and peers</td>
and
<td class="blue"><i class="icon-bulb"></i><strong>Mastermind Mindset</strong><br /> <span class="small-text">(mastermind is for you)</span></td>
to
<td class="blue1">Books, blogs, seminars and peers</td>
<td class="blue2"><i class="icon-bulb"></i><strong>Mastermind Mindset</strong><br /> <span class="small-text">(mastermind is for you)</span></td>
Then add the classes in CSS:
.blue1{
border-radius:8px 8px 0px 0px !important;
background-color: #2a9ce0;
color: #fff;
border-bottom: 1px solid #55ace0;
}
.blue2{
border-radius:0px 0px 8px 8px !important;
background-color: #2a9ce0;
color: #fff;
border-bottom: 1px solid #55ace0;
}