Display header and footer in every page is breaks by long table - php

I want to set all header and footer in all page in a pdf with mpdf,
So, my code looked like this :
<!DOCTYPE html>
<html>
<head>
<title>Data Category</title>
<style type="text/css">
.page{
padding-top:2.5cm;
padding-right:1.5cm;
padding-left:1cm;
padding-bottom:5cm;
}
table{
border-spacing:0;
border-collapse: collapse;
width:100%;
page-break-inside:auto;
}
table td, table th{
border: 1px solid black;
}
</style>
</head>
<body>
<div class="page">
<table border="0">
<thead>
<tr>
<th>No</th>
<th>Tanggal</th>
<th>Jam</th>
<th>No struk</th>
<th>Nama</th>
<th>Quantity</th>
<th>Nama Item</th>
<th>Harga Jual</th>
<th>Sub total</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
foreach ($data as $key => $value) {
?>
<tr>
<td><?= $no++ ?></td>
<td><?= $value['date_format'] ?></td>
<td><?= $value['jam'] ?></td>
<td><?= $value['struk_no'] ?></td>
<td><?= $value['nama_karyawan'] ?></td>
<td><?= $value['jumlah_jual'] ?></td>
<td><?= $value['nama_item'] ?></td>
<td><?= $value['harga_jual'] ?></td>
<td><?= $value['subtotal'] ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</body>
I have alread read their docs from here : mpdf docs.
But, when my table is loaded more than one page, the table breaks the header:
$detail = Yii::$app->db->createCommand($this->getSqlReportDetail($parseStart, $parseEnd))->queryAll();
$html = $this->renderPartial('_report_detail', ['data' => $detail]);
$mpdf = new \mPDF('c', 'A4', '', '', 0, 0, 0, 0, 0, 0);
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
$mpdf->SetHTMLHeader(''
. '<div style="text-align: center; font-weight: bold;">'
. '<h1>Hair Deeper Salon</h1><br>'
. '<hr>'
. '</div>'
);
$mpdf->SetHTMLFooter('
<table width="100%" style="vertical-align: bottom; font-family: serif; font-size: 8pt; color: #000000; font-weight: bold; font-style: italic;">
<tr>
<td width="33%"><span style="font-weight: bold; font-style: italic;">{DATE j-m-Y}</span></td>
<td width="33%" align="center" style="font-weight: bold; font-style: italic;">{PAGENO}/{nbpg}</td>
<td width="33%" style="text-align: right; ">My document</td>
</tr>
</table>
');
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;
This is the document right now :

Try using this before setting header and footer
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->setAutoBottomMargin = 'stretch';

Related

Posisition Absolute on Mpdf Kartik not working

Continue from the question Yii2 mPdf Kartik: Set Height and Width Paper
I have problem width position absolute on page footer.
I have set it up position: absolute; and bottom: 0;
But page footer not in actual position.
The position should be like this:
this is my html code:
<?php
$pages = 1;
$pageof = 1;
$totalPageof = ceil(count($model->details) /10);
$index = 0;
?>
<?php if(count($details) > 0) : ?>
<div class="page-wrapper">
<?php foreach($details as $detail) :
$index += 1;
?>
<?php if($pages == 1) : ?>
<div class="page-layout">
<!-- HEADER -->
<div class="page-header">
<table class="table-header">
<tbody>
<tr>
<td class="font12" width="250"><strong>COMPANY NAME</strong></td>
<td class="font14" width="250"><strong>PROFORMA INVOICE</strong></td>
<td>
<table>
<tr>
<td class="font11" width="80">NO. PO</td>
<td class="font11" width="10">:</td>
<td class="font11"><?=$model->no_po?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="font11" width="250">
<p>COMPANY ADDRESS</p>
</td>
<td class="font14" width="250"><?=$model->no_rorder?></td>
<td>
<table>
<tr>
<td class="font10" width="80"><?=(!empty($model->tgl_po)) ? date('d-M-Y', strtotime($model->tgl_po)) : NULL ?></td>
<td class="font10"><?=(!empty($model->tgl_tempo)) ? 'DUE DATE '. date(' d-M-Y', strtotime($model->tgl_tempo)) : 'DUE DATE -' ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="padding: 0;">
<table>
<tr>
<td class="font12" colspan="3">COMPANY PHONE</td>
</tr>
<tr>
<td class="font10" width="60">NPWP</td>
<td class="font10" width="10"></td>
<td class="font10"><?=isset($model->distributor) ? $model->distributor->npwp : '-' ?></td>
</tr>
<tr>
<td class="font10" width="60">SALESMAN</td>
<td class="font10" width="10">:</td>
<td class="font11"><?=isset($model->sales) ? (isset($model->sales->code)) ? $model->sales->code.'-'.$model->sales->name : $model->sales->name : '-' ?></td>
</tr>
<tr>
<td class="font10" width="60">NOTICE</td>
<td class="font10" width="10">:</td>
<td class="font10"><?=isset($model->salesType) ? $model->salesType->name : '-' ?></td>
</tr>
</table>
</td>
<td colspan="2">
<table>
<tbody>
<tr>
<td rowspan="2" class="font12 grid-1">Kepada YTH</td>
<td class="grid-2">
<p class="font12"><?=isset($model->outlet) ? $model->outlet_code.' - '.$model->outlet->name : '-' ?></p>
<p class="font12"><?=isset($model->outlet) ? $model->outlet->address : '-' ?></p>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td class="font10 text-left" style="padding-left:180px;" colspan="2">
<span>
Phone <?=isset($model->outlet) ? $model->outlet->phone_1 : '-' ?>
</span>
</td>
</tr>
<tr>
<td class="font10" width="200"><?=isset($model->outlet) ? $model->outlet->npwp : '-'?></td>
<td class="font10"><?='Page '. $pageof++ .' Of '. $totalPageof ?></td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<!-- /HEADER -->
<?php endif; ?>
<!-- /endif pages header -->
<!-- CONTENT -->
<?php if($pages == 1) : ?>
<div class="page-content">
<table class="table-content">
<thead>
<tr>
<th>KODE#</th>
<th>PRODUK</th>
<th colspan="5">QUANTITY</th>
<th>PRICE</th>
<th>DISC</th>
<th>SUB TOTAL</th>
</tr>
</thead>
<tbody>
<?php endif; ?>
<!-- /endif pages content -->
<tr>
<td class="text-right"><?=(isset($detail['typeproduct'])) ? '*'. $detail['product_code'] : $detail['product_code']?></td>
<td><?=$detail['product_name']?></td>
<td><?=($detail['comp_1'] && $detail['zqty_1'] != 0) ? number_format($detail['zqty_1']).'.'.$detail['comp_1'] : ''?></td>
<td><?=($detail['comp_2'] && $detail['zqty_2'] != 0) ? number_format($detail['zqty_2']).'.'.$detail['comp_2'] : ''?></td>
<td><?=($detail['comp_3'] && $detail['zqty_3'] != 0) ? number_format($detail['zqty_3']).'.'.$detail['comp_3'] : ''?></td>
<td><?=($detail['comp_4'] && $detail['zqty_4'] != 0) ? number_format($detail['zqty_4']).'.'.$detail['comp_4'] : ''?></td>
<td><?=($detail['comp_5'] && $detail['zqty_5'] != 0) ? number_format($detail['zqty_5']).'.'.$detail['comp_5'] : ''?></td>
<td class="text-right"><?=(!is_null($detail['zsprice_1'])) ? number_format($detail['zsprice_1'], 0, ',', '.') : ''?></td>
<td class="text-right"></td>
<td class="text-right"><?=(!is_null($detail['zjum_j'])) ? number_format($detail['zjum_j'], 0, ',', '.') : ''?></td>
</tr>
<!-- COUNTER ITEM -->
<?php if($pages == 10 || $index == count($details)) : ?>
</tbody>
</table>
</div>
<!-- /CONTENT -->
<!-- FOOTER -->
<?php if($totalPageof == ($pageof-1)) : ?>
<div class="page-footer">
<table class="table-footer">
<tbody>
<tr>
<td class="grid-1">
<p class="font9"><?=(!empty($model->keterangan)) ? '<i>##</i>'. $model->keterangan : NULL ?></p>
</td>
<td class="grid-2 text-right" width="200">
<p class="font12"><strong><?=(!$model->post) ? '' : '### PENCETAKAN ULANG ##' ?></strong></p>
<table>
<tbody>
<tr>
<td class="font9" width="60">Cetakan ke</td>
<td class="font9">:</td>
<td class="font9 text-right"><?= (!empty($model->post)) ? $model->print : 0 ?></td>
<td></td>
<td class="font9" width="60">Sub Total</td>
<td class="font9">:</td>
<td class="font9 text-right"><?=number_format($realJumlah['total_j'], 0, ',', '.')?></td>
</tr>
<tr>
<td class="font9" width="60">Total Pcode</td>
<td class="font9">:</td>
<td class="font9 text-right"><?= count($details) ?></td>
<td></td>
<td class="font9" width="60">Disc Inv</td>
<td class="font9">:</td>
<td class="font9 text-right"><?=number_format($realJumlah['disc_percent'], 0, ',', '.')?></td>
</tr>
<tr>
<td class="font9" width="60">Point</td>
<td class="font9">:</td>
<td class="font9 text-right"><?=number_format($realJumlah['disc_point'], 0, ',', '.')?></td>
<td></td>
<td class="font9" width="60">DPP</td>
<td class="font9">:</td>
<td class="font9 text-right"><?=number_format($realJumlah['dpp'], 0, ',', '.')?></td>
</tr>
<tr>
<td colspan="4"></td>
<td class="font9" width="60">PPN</td>
<td class="font9">:</td>
<td class="font9 text-right"><?=number_format($realJumlah['ppn'], 0, ',', '.')?></td>
</tr>
<tr>
<td colspan="4"></td>
<td class="font10" width="60"><strong>TOTAL</strong></td>
<td class="font10">:</td>
<td class="font10 text-right"><strong><?=number_format($realJumlah['inv'], 0, ',', '.')?></strong></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="grid-1"></td>
<td class="grid-2 font10 money text-justify"><?=$realJumlah['terbilang']?></td>
</tr>
<tr>
<td class="grid-1">
<p class="font10">Admin SPV Gudang Pengirim Outlet</p>
<p class="font10">Produck yang sudah diterima harap diperiksa kembali</p>
<p class="color-white">----------------------------------------------------</p>
<p>----------------------------------------------------</p>
</td>
<td class="grid-2" style="padding-left: 80px;">
<table>
<tbody>
<tr>
<td class="font9">User</td>
<td class="font9">:</td>
<td class="font9"><?=Yii::$app->user->identity->profile->user->username?></td>
</tr>
<tr>
<td class="font9">Printed</td>
<td class="font9">:</td>
<td class="font9"><?= date('H:i:s', time()) ?></td>
</tr>
<tr>
<td class="font9">on</td>
<td class="font9">:</td>
<td class="font9"><?=date('d/m/Y')?></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<?php endif; ?>
<!-- /FOOTER -->
<?php endif; ?>
<!-- /COUNTER ITEM -->
</div>
<?php
$pages++;
if($pages > 10)
$pages = 1;
endforeach;
?>
<!-- /endforeach -->
</div>
<?php endif; ?>
<!-- /endif count -->
And this my css code:
/** page layout */
.page-wrapper {
height: 13.6cm;
width: 21.2cm;
}
.page-layout {
height: 13.6cm;
width: 21.2cm;
}
.page-footer {
bottom: 0;
position: absolute;
}
/** end page layout */
/** table style */
.table-header {
width: 100%;
}
.table-header tbody tr td {
padding-bottom: 0;
padding-top: 0;
vertical-align: text-bottom;
}
.table-header tbody tr td p {
margin: 0;
}
.table-header tbody tr td table {
width: 100%;
}
.table-header tbody tr td table tbody tr td.grid-1 {
width: 20%;
}
.table-header tbody tr td table tbody tr td.grid-2 {
width: 80%;
}
.table-content {
font-family: 'Couriere';
width: 100%;
}
.table-content thead tr th {
border-bottom: 1px dashed #000;
font-size: 12px;
font-weight: 300;
text-align: center;
}
.table-content tbody tr td {
font-size: 12px;
padding-bottom: 0;
padding-top: 0;
}
.table-footer {
width: 100%;
}
.table-footer tbody tr td {
padding-bottom: 0;
padding-top: 0;
position: relative;
}
.table-footer tbody tr td p {
margin: 0;
}
.table-footer tbody tr td.grid-1 {
vertical-align: text-bottom;
width: 70%;
}
.table-footer tbody tr td.grid-2 {
width: 30%;
}
.table-footer tbody tr td.money {
padding-left: 40px;
}
.table-footer tbody tr td table {
width: 100%;
}
/** end table style */
/** custom child */
.font9 {
font-size: 9px;
}
.font10 {
font-size: 10px;
}
.font11 {
font-size: 11px;
}
.font12 {
font-size: 12px;
}
.font14 {
font-size: 14px;
}
.text-right {
text-align: right;
}
.text-justify {
text-align: justify;
}
.color-white {
color: #fff;
}
/** end custom child */
May be someone has experienced it, hopefully it can be helped.

Scrollable Echo DB Table with Fix header

I'm trying to make a scrollable table with fix header. This works well if the data is entered to HTML, but when I try to echo content of my database to the table, the scroll bar messes up and my header is no longer fixed. As seen in the photo, the scroll bar is on each table entry. I've tried .div wrapping up the table body as some did but it doesn't work.
body{
background: lightblue;
}
#tble th {
text-align: left;
background-color: green;
color: white;
}
table{
display: block;
border: 1px solid;
margin-top: 10px;
width: 350px;
}
tbody{
display: block;
height: 50px;
overflow-y: scroll;
}
th {
width: 75px;
}
td {
width: 75px;
}
<html lang="en">
<body>
<table align="center" id="tble">
<thead>
<th style="text-align: center">ID</th>
<th style="text-align: center">Username</th>
<th style="text-align: center">Rights</th>
<th style="text-align: center">Age</th>
</thead>
<tbody>
<tr>
<?php
$conn = mysqli_connect("localhost", "root", "", "account");
$result = mysqli_query($conn, "SELECT * FROM account.log WHERE rights IN ('Admin','User')", MYSQLI_USE_RESULT) or die(mysql_error());
while($row = mysqli_fetch_array( $result )) {
?>
<td style="text-align: center"><?php echo $row['id']; ?></td>
<td style="text-align: center"><?php echo $row['user']; ?></td>
<td style="text-align: center"><?php echo $row['rights']; ?></td>
<td style="text-align: center"><?php echo $row['age']; ?></td>
</tr>
</tbody>
<?php
}
?>
</body>
</table>
Is there something I missed? Hoping someone could point me to the right direction.
<!-- language: lang-html -->
<html lang="en">
<body>
<table align="center" id="tble">
<thead>
<th style="text-align: center">ID</th>
<th style="text-align: center">Username</th>
<th style="text-align: center">Rights</th>
<th style="text-align: center">Age</th>
</thead>
<tbody>
<tr>//move this from here
<?php
$conn = mysqli_connect("localhost", "root", "", "account");
$result = mysqli_query($conn, "SELECT * FROM account.log WHERE rights IN ('Admin','User')", MYSQLI_USE_RESULT) or die(mysql_error());
while($row = mysqli_fetch_array( $result )) {
?>
<tr> //to here
<td style="text-align: center"><?php echo $row['id']; ?></td>
<td style="text-align: center"><?php echo $row['user']; ?></td>
<td style="text-align: center"><?php echo $row['rights']; ?></td>
<td style="text-align: center"><?php echo $row['age']; ?></td>
</tr>
</tbody>
<?php
}
?>
</body>
</table>

How to make a table responsive?

Given below is my table which i wanna make responsive.
<table style="width:100%" class="table table-hover">
<tr>
<th>Booking Date</th>
<th>Booking Id</th>
<th>Amount</th>
<th>Movie Name</th>
<th>Theatre Name</th>
</tr>
<?php
foreach ( $data as $history )
{
?>
<tr>
<td> <?php print_r( $history->booking_date );?></td>
<td> <?php print_r( $history->booking_id ); ?></td>
<td> <?php print_r( $history->amount ); ?></td>
<?php $movie = Movies::find()->where( [ 'id' => $history->movie_id ] )->one(); ?>
<td><?php print_r( $movie->movie_name ); ?></td>
<?php $theatre = Theatres::find()->where( [ 'id' => $history->theatre_id ] )->one();?>
<td><?php print_r( $theatre->theatre_name ); ?></td>
</tr>
<?php
}
?>
</table>
class="table table-hover" was used so that when i hover over the rows i get a
different color. I changed it to class="table table-responsive" but even then
i found my table not responsive. What should i do to make it responsive?
<style type="text/css">
/*
Generic Styling, for Desktops/Laptops
*/
.table-hover {
width: 100%;
border-collapse: collapse;
}
/* Zebra striping */
tr:nth-of-type(odd) {
background: #eee;
}
th {
background: #333;
color: white;
font-weight: bold;
}
td, th {
padding: 6px;
border: 1px solid #ccc;
text-align: left;
}
tr:hover {
background-color: lightyellow;
}
</style>
<table class="table table-hover">
<tr>
<th>Booking Date</th>
<th>Booking Id</th>
<th>Amount</th>
<th>Movie Name</th>
<th>Theatre Name</th>
</tr>
<?php
foreach ( $data as $history )
{
?>
<tr>
<td> <?php print_r( $history->booking_date );?></td>
<td> <?php print_r( $history->booking_id ); ?></td>
<td> <?php print_r( $history->amount ); ?></td>
<?php $movie = Movies::find()->where( [ 'id' => $history->movie_id ] )->one(); ?>
<td><?php print_r( $movie->movie_name ); ?></td>
<?php $theatre = Theatres::find()->where( [ 'id' => $history->theatre_id ] )->one();?>
<td><?php print_r( $theatre->theatre_name ); ?></td>
</tr>
<?php
}
?>
</table>
try this one
source: https://css-tricks.com/responsive-data-tables/

"Nice" html table using SQL results

I currently have this html table using SQL results to fill it:
<table>
<table border="1">
<tr>
<th>Username</th>
<th>holid</th>
<th>Start date</th>
<th>end date</th>
<th>Work days off</th>
</tr>
<?php foreach($rows as $row): ?>
<table border="1">
<tr>
<td><?php echo htmlentities($row['username'], ENT_QUOTES, 'UTF-8');?></td>
<td><?php echo htmlentities($row['starthol'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlentities($row['endhol'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlentities($row['days'], ENT_QUOTES, 'UTF-8'); ?></td>
<td>Approve</td>
<td>Reject</td>
</tr>
<?php endforeach; ?>
</table>
This works fine and everything, but the table is very messy and the headings are out of line. Is there a simple way to make this cleaner (php beginner).
Here is the extra table tag removed coding and see below for the css coding.
<table border="1">
<tr>
<th>Username</th>
<th>holid</th>
<th>Start date</th>
<th>end date</th>
<th>Work days off</th>
</tr>
<?php foreach($rows as $row): ?>
<tr>
<td><?php echo htmlentities($row['username'], ENT_QUOTES, 'UTF-8');?></td>
<td><?php echo htmlentities($row['starthol'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlentities($row['endhol'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlentities($row['days'], ENT_QUOTES, 'UTF-8'); ?></td>
<td>Approve</td>
<td>Reject</td>
</tr>
<?php endforeach; ?>
</table>
/*css styles*/
table {
border-collapse: collapse;
}
/* Zebra striping */
tr:nth-of-type(odd) {
background: #eee;
}
th {
background: #333;
color: white;
font-weight: bold;
}
td, th {
padding: 6px;
border: 1px solid #ccc;
text-align: left;
}
Delete the second <table border="1">, the one below the foreach instruction.
EDIT: And one of the first ones as well. Every <table> tag should have one corresponding </table> (that goes for all tags in HTML!)
Also, try to match <th>s with <td>s. Right now there are 5 <th>s and each row has 6 <td>s.

Convert From PHP and PDF

I need to convert from Php(html Table) to Pdf. I have used the DOM PDf for the conversion. But i didn't get the proper view in pdf. please find the below images.
Pdf View
HTML View
Code Below:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<?php if(count($this->userDetails)>=1){ for($a=0;$a<count($this->userDetails);$a++){ $user = $this->userDetails[$a]; ?>
<body>
<div style="background-image: url(http://192.168.2.26/skins/schooladmin/images/id_bg.png); background-repeat: repeat; width:400px; height:220px;margin:10px 0px 0px 10px;float:left;position:relative;">
<table style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold; color:#fff; background-image:url(http://192.168.2.26/skins/schooladmin/images/id_white_bg.png); background-repeat:no-repeat;" width="100%" border="0" cellpadding="5" cellspacing="5">
<tr>
<td style="background-image: url(http://192.168.2.26/skins/schooladmin/images/schoollogo.png); background-repeat:no-repeat; width:36px; height:61px;"> </td>
<td colspan="2"><?php echo $this->schoolDetails['name'] ?></td>
</tr>
<?php
if($user){
$user['userdetails']['name'] = $user['userdetails']['firstname'].$user['userdetails']['lastname'];
$photoPath = BASE_PATH."/uploads/photos/student/".$user['userdetails']['photo'];
if(!file_exists($photoPath)){
$photoPath = BASE_PATH."/skins/schooladmin/images/id_photo.png";
}
}else{
$photoPath = BASE_PATH."/skins/schooladmin/images/id_photo.png";
}
?>
<tr>
<td style="background-image: url(<?php echo $photoPath; ?>); background-repeat:no-repeat; width:82px; height:82px;"> </td>
<td colspan="2">
<table width="100%" border="0" cellspacing="3" cellpadding="3" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; color:#fff;" >
<?php if($this->templateDetails['template']){
for($i=0;$i<1;$i++){
for($j=0;$j<count($this->templateDetails['template_details']);$j++){
if($this->templateDetails['template_details'][$j]['type'] == "text" && $this->templateDetails['template_details'][$j]['page'] == "front"){
?>
<tr>
<td width="38%"><?php echo $this->templateDetails['template_details'][$j]['label']; ?></td>
<td width="62%"><?php echo #$user['userdetails'][$this->templateDetails['template_details'][$j]['field']]; ?></td>
</tr>
<?php } } } } ?>
</table>
</td>
</tr>
<tr>
<td colspan="3" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; color:#fff;" align="center"><?php echo $this->schoolDetails['address'] ?>, <?php echo $this->schoolDetails['address2'] ?>, <?php echo $this->schoolDetails['city'] ?> - <?php echo $this->schoolDetails['zipcode'] ?></td>
</tr>
<tr>
<td colspan="3" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; color:#fff;" align="center">Ph: <?php echo $this->schoolDetails['contactno'] ?></td>
</tr>
</table>
</div>
<div style="background-image: url(http://192.168.2.26/skins/schooladmin/images/id_bg.png); background-repeat: repeat; width:400px; height:220px;margin:10px 0px 0px 10px;float:left;position:relative;">
<table style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold; color:#fff; background-image:url(http://192.168.2.26/skins/schooladmin/images/id_white_bg.png); background-repeat:no-repeat;" width="100%" border="0" cellpadding="5" cellspacing="5">
<?php if($this->templateDetails['template']){
for($i=0;$i<1;$i++){
for($j=0;$j<count($this->templateDetails['template_details']);$j++){
if($this->templateDetails['template_details'][$j]['type'] == "text" && $this->templateDetails['template_details'][$j]['page'] == "back"){
?>
<tr>
<td width="38%"><?php echo $this->templateDetails['template_details'][$j]['label']; ?></td>
<td width="62%"><?php echo #$user['userdetails'][$this->templateDetails['template_details'][$j]['field']]; ?></td>
</tr>
<?php } } } } ?>
</table>
</div>
<?php } } ?>
</body>
</html>
I recommend not trying to massage your HTML so that it converts to PDF this way. You'll expend far to much effort tweaking things that can change when you switch rendering engines or even printers.
You'll have an easier time if you create your PDFs natively using FPDF or TCPDF. For example (just to get you started):
<?php
require_once('/path/to/tcpdf.php');
// misc variables
$lightblue = array(100, 100, 250);
$darkblue = array(0, 0, 255);
$white = array(255, 255, 255);
// prepare new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetFont('helvetica', 'B', 20);
// add a page
$pdf->AddPage();
// set the coordinates of the gradient
$coords = array(0, 1, 1, 0);
// paint a linear gradient
$pdf->LinearGradient(20, 45, 105, 60, $lightblue, $darkblue, $coords);
// write text
$pdf->SetTextColorArray($white);
$pdf->Text(40, 50, 'hello');
$pdf->Text(40, 60, 'world');
// Close and output PDF document
$pdf->Output('tkexample.pdf', 'I');
For geeting 100% same view, use php fpdf library.You can get all the supports, tutorials and download from here

Categories