I am generating invoices using MPDF. My item rows are dynamic so the height of table which shows items should be flexible. When I am printing the PDF using following code:
<!-- Latest compiled and minified CSS -->
<?php echo $this->Html->css(array('bootstrap.min','AdminLTE.min','skin-green','font-awesome.min')); ?>
<style type="text/css">
.products{
width: 100%;
border-collapse: collapse;
}
h2,h3{
margin: 0;
padding:0;
}
.border{
border: 1px solid black;
padding:5px;
}
table.products{
border: 1px solid black;
height: 500px;
margin-left: -6px;
margin-right: -6px;
margin-bottom: -6px;
}
.products tr td{
padding:5px;
border:1px solid #333;
}
.products tr th{
padding:5px;
border:1px solid #333;
}
.pull-right{
float: right;
}
</style>
<!-- title row -->
<div class="border">
<table width="100%">
<tr>
<td style="width:35%">
</td>
<td style="width:35%" align="center">
Estimate
</td>
<td style="width:35%" align="right">
Date: <?php echo date('d-m-Y',strtotime($invoice['Invoice']['dated'])); ?>
</td>
</tr>
<tr>
<td colspan="3" align="center">
<br>
<h3>Invoice Heading</h3>
</td>
</tr>
</table>
<hr/>
<div class="row">
<div class="col-xs-12 border-right">
To: <?php echo $invoice['Invoice']['user']; ?><br>
Mobile.: <?php echo $invoice['Invoice']['mobile']; ?><br>
Address: <?php echo $invoice['Invoice']['address']; ?><br>
</div>
</div>
<hr/>
<!-- Table row -->
<div class="row">
<div class="col-xs-12 table-responsive">
<table class="products">
<thead>
<tr>
<th width="60"><?php echo __('Sr. No.'); ?></th>
<th><?php echo __('Quantity'); ?></th>
<th width="250"><?php echo __('Particulars'); ?></th>
<th><?php echo __('Rate'); ?></th>
<th><?php echo __('Amount'); ?></th>
</tr>
</thead>
<tbody>
<?php $i = 0; foreach ($invoice['InvoiceDetail'] as $invoiceDetail): $i++; ?>
<tr>
<td><?php echo $i; ?></td>
<td><?php echo $invoiceDetail['quantity']; ?></td>
<td><?php echo $invoiceDetail['Item']['name']; ?></td>
<td><?php echo $invoiceDetail['price']; ?></td>
<td align="right"><?php echo $invoiceDetail['amount'] ?></td>
</tr>
<?php endforeach; ?>
<tr>
<td colspan="3"></td>
<td>Total: </td>
<td align="right"><i class="fa fa-inr"></i> <?php echo number_format((float)$invoice['Invoice']['total'], 2, '.', ''); ?>
</td>
</tr>
<tr>
<td colspan="5">Amount in words: Rs.<?php echo $c2w ?></td>
</tr>
</tbody>
</table>
</div><!-- /.col -->
</div><!-- /.row -->
</div>
But I need to print it as follows:
I have tried using line-height but it distorts the view because valign in td will not align the content at top.
With line-height:100px
in TD print looks like follows:
Is there a way to fill the complete page by increasing the height of items table dynamically.