How do I use Page Break in Dompdf laravel 5.5? - php

I'm having trouble designing the pdf of my system. here's a pic of my pdf:
What I want to do is to limit the number of items in the table by 10 items after that the rest goes to the next page with the same header and footer which is fixed already. just like this:
Purchase Request PDF
Here's my code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PDF</title>
<link href="{{ asset('css/bootstrap.min.css') }}" rel="stylesheet">
<style>
#items tr{border:1px solid #000000;}
#items tbody tr td{border:1px solid #000000;}
#items thead td{background-color:#231F20;color:#FFFFFF;}
.header { position: fixed; left: 0px; top: -40px; right: 0px;}
.footer { position: fixed; left: 0px; bottom: 200px; right: 0px;}
</style>
<link rel="stylesheet" href="{{ asset('css/lato.css') }}">
<link href="https://fonts.googleapis.com/css?family=Libre+Barcode+128" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
<div class="header">
<div class="row">
<div class="col-xs-3" style="font-family: 'Libre Barcode 128', cursive; font-size: 35px;padding: 10px 0px 0px 0px;">{{$pr->pr_form_no}}</div>
<div class="col-xs-9">
<table cellspacing='0' cellpadding='5' style="border-width: 0 !important;padding:0px 0px 0px 60px;">
<tr>
<td style="padding: 10px;"><img src="{{asset('images/sfclogo.png')}}" width="50px" height="50px"></td>
<td>
<table style="text-align: center;style='width:45%'">
<tr><td>REPUBLIC OF THE PHILIPPINES</td></tr>
<tr><td>PROVINCE OF LA UNION</td></tr>
<tr><td>CITY OF SAN FERNANDO</td></tr>
</table>
</td>
<th style="padding-top: 10px;padding-left: 10px"><p style="background-color: #000;color: #FFF; text-align: center;padding: 10px;">PR</p></th>
</tr>
</table>
</div>
</div>
<div class="row">
<div class="col-md-12" style="text-align: center;color: white;background-color: black; font-size: 18px">
PURCHASE REQUEST
</div><br>
</div>
<div class="row">
<table style='width:100%;border:1px solid #000000;font-size:11pt;' cellspacing='0' cellpadding='5' class='font1'>
<tr>
<td style='width:40%'>
<table style='width:90%;padding-right: 0px;' cellpadding='0' cellspacing='0'>
<tr>
<td style='width:100%;padding:1px;padding-left:10px;' colspan='2'>DEPARTMENT:</td>
</tr>
<tr>
<td style='width:100%;padding:0px;padding-left:10px;' colspan='2'>{{$dept->office_name}}<hr style='color:#000000;height:1px;margin-bottom:3px;margin-top:0px;padding-left:10px;' /></td>
</tr>
<tr>
<td style='width:15%;padding:1px;padding-left:10px;'>SECTION:</td>
<td style='width:75%;padding:0px;padding-left:0px;'>{{$section->office_name}}<hr style='color:#000000;height:1px;margin-bottom:3px;margin-top:0px;' /></td>
</tr>
</table>
</td>
<td style='width:30%;'>
<table style='width:90%;' cellpadding='0' cellspacing='0'>
<tr>
<td style='width:20%;padding:1px;'>PR No.</td>
<td style='width:70%;padding:0px;border-bottom:1px solid #000000;'>{{$pr->pr_form_no}}</td>
</tr>
<tr>
<td style='width:20%;padding:1px;'>SAI No.</td>
<td style='width:70%;padding:0px;border-bottom:1px solid #000000;'></td>
</tr>
<tr>
<td style='width:20%;padding:1px;'>ObR No.</td>
<td style='width:70%;padding:0px;border-bottom:1px solid #000000;'></td>
</tr>
</table>
</td>
<td style='width:30%'>
<table style='width:95%;' cellpadding='0' cellspacing='0'>
<tr>
<td style='width:15%;padding:1px;'>Date</td>
<td style='width:70%;padding:0px;border-bottom:1px solid #000000;'> {{$dt->toFormattedDateString()}}</td>
</tr>
<tr>
<td style='width:15%;padding:1px;'>Budget</td>
<td style='width:70%;padding:0px;border-bottom:1px solid #000000;'><strong> PHP {{number_format($pr->budget_alloc,2)}}</strong></td>
</tr>
<tr>
<td style='width:15%;padding:1px;'>Supplier</td>
<td style='width:70%;padding:0px;border-bottom:1px solid #000;'> {{$pr->supplier_type}}</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
<div class="footer">
<div class="row">
<table style='width:100%;border:1px solid #000000;font-size:12px;margin-left:auto;margin-right:auto;margin-top:40px;' cellspacing='0' cellpadding='3' class='font1'>
<tr>
<td style='width:39%; font-weight:bold;text-align:left;border:1px solid #000000;'>
REQUESTING OFFICE<br/><br/><br/><br/>
</td>
<td style='width:60%;border:1px solid #000000;vertical-align:top;font-weight:bold;' colspan='2' rowspan='3'>
PURPOSE<br/>
<div style='width:100%;text-align:center;font-weight:normal;font-size:11pt;' class='font1'>
{{$pr->purpose}}
</div>
</td>
</tr>
<tr>
<td style='border:1px solid #000000;height:19px;text-align:center;text-transform:uppercase;font-weight:bold;'>
{{$pr->requestor_name}}
</td>
</tr>
<tr>
<td style='text-align:center;border:1px solid #000000;text-transform:uppercase;height:19px;font-weight:bold'>
{{$pr->requestor_position}}
</td>
</tr>
<tr>
<td colspan='3' style='background-color:#000000;height:20px;'>
</tr>
<tr>
<td style='width:33%; font-weight:bold;text-align:left;border:1px solid #000000;'>
APPROPRIATION AVAILABLE
</td>
<td style='width:33%; font-weight:bold;text-align:left;border:1px solid #000000;'>
FUNDS AVAILABLE
</td>
<td style='width:33%; font-weight:bold;text-align:left;border:1px solid #000000;'>
APPROVED
</td>
</tr>
<tr>
<td style='border:1px solid #000000;height:25px;text-align:center;text-transform:uppercase;font-weight:bold;'>
</td>
<td style='border:1px solid #000000;height:25px;text-align:center;text-transform:uppercase;font-weight:bold;'>
</td>
<td style='border:1px solid #000000;height:25px;text-align:center;text-transform:uppercase;font-weight:bold;'>
</td>
</tr>
<tr>
<td style='width:33%; font-weight:bold;text-align:center;border:1px solid #000000;text-transform:uppercase;'>
{{$aa->name}}<br/>
{{$aa->position}}
</td>
<td style='width:33%; font-weight:bold;text-align:center;border:1px solid #000000;text-transform:uppercase;'>
{{$c->name}}<br/>
{{$c->position}}
</td>
<td style='width:33%; font-weight:bold;text-align:center;border:1px solid #000000;text-transform:uppercase;'>
{{$approval->name}}<br/>
{{$approval->position}}
</td>
</tr>
</table>
</div>
<div class="row">
<div style='float:left;font-weight:normal;font-style:italic;font-size:7pt;width:40%;text-align:left;'>{{$created_code}}</div>
</div>
</div>
<div class="content" >
<div class="row">
<table style='width:100%;font-size:14px;text-align:center;border:1px solid #000000;' id='items' cellpadding='0' cellspacing='0'>
<thead>
<tr>
<td style='width:7%;font-weight:bold;'>ITEM NO.</td>
<td style='width:7%;font-weight:bold;'>QTY</td>
<td style='width:7%;font-weight:bold;'>UNIT</td>
<td style='width:49%;font-weight:bold;'>DESCRIPTION</td>
<td style='width:15%;font-weight:bold;'>ESTIMATED UNIT OF</td>
<td style='width:15%;font-weight:bold;'>ESTIMATED COST</td>
</tr>
</thead>
<tbody >
#foreach($list as $indexKey => $list)
<tr>
<td>{{$indexKey}}</td>
<td>{{$list->pr_qty}}</td>
<td>{{$list->pr_unit}}</td>
<td>{{$list->pr_description}}</td>
<td style='text-align: right;'>{{$list->pr_cost_per_unit}}</td>
<td style='text-align: right;'>{{$list->pr_estimated_cost}}</td>
</tr>
#if($indexKey >= 9)
#break
#endif
#endforeach
#for($i = $count; $i < 10; $i++)
<tr><td> </td><td> </td> <td> </td><td> </td><td> </td><td> </td></tr>
#endfor
</tbody>
<tfoot>
<tr style="background-color: #b0b1b2;">
<td colspan="5" style="text-align: right; font-weight: bold;">GRAND TOTAL</td>
<td style="text-align: right; font-weight: bold;">
{{number_format($grand_total,2)}}
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<script src="{{ asset('js/jquery.min.js') }}"></script>
<script src="{{ asset('js/bootstrap.min.js') }}"></script>
</body>
</html>
I already attempted to use the break function of the blade to stop the loop when the items shown is already 10.
*Also sorry if the code looks like hell.

you can use some css styling for it just like below:
<style>
.page-break {
page-break-after: always;
}
</style>
<h1>page</h1>
<div class="page-break"></div>
<h1>Someother Page</h1>
if you want to make a page break after for example 5 divs then you can do something like this:
#php $check=0 #endphp
#foreach($array as $item)
#php $check++ #endphp
<!-- your code or something like divs -->
#if( $check % 5 == 0 )
#php echo '<div class="page-break"></div>'; #endphp ....
#endif
#endforeach
Hope you will get the idea from it.

Related

How to display 1 data if the same id and when clicked displays the same id in controller laravel

How to display 1 data if the same id and when clicked displays the same id in controller laravel
how do you fix it?
controller
public function daftar_paket(){
if(!Session::get('login')){
return redirect('/login')->with('alert','Kamu harus login dulu');
}
else{
$paket = DB::table('tbl_paket as a')
->select('*')
->join('tbl_profil_penyedia as b', 'a.id_profil_penyedia', '=', 'b.id_profil_penyedia')
->join('tbl_kategori_belanja as c', 'a.id_kategori_belanja', '=', 'c.id_kategori_belanja')
->join('tbl_kategori_produk as d', 'a.id_kategori_produk', '=', 'd.id_kategori_produk')
->join('tbl_pagu as e', 'a.id_pagu', '=', 'e.id_pagu')
->join('tbl_pembayaran as f', 'a.id_pembayaran', '=', 'f.id_pembayaran')
->get();
$pesanan = DB::table('tbl_pesanan as a')
->select('*')
->join('tbl_bmn2 as b', 'a.kode_bmn', '=', 'b.kode_bmn')
->join('tbl_paket as c', 'a.id_paket', '=', 'c.id_paket')
->join('tbl_profil_penyedia as d', 'c.id_profil_penyedia', '=', 'd.id_profil_penyedia')
->join('tbl_kategori_produk as e', 'c.id_kategori_produk', '=', 'e.id_kategori_produk')
->get();
return view('paket/home_daftar_paket',['paket' => $paket, 'pesanan' => $pesanan]);
}
}
adding this can help?
view
#foreach($pesanan as $p)
#php $status = $p->status_paket; #endphp
#if ($status == 2)
<table style="width:100%">
<tr>
<td style="width: 15%;"><b>Nama Pesanan</b></td>
<td style="width: 1%;">:</td>
<td>{{$p->nama_pesanan }}</td>
</tr>
<tr>
<td style="width: 15%;"><b>Jenis Belanja</b></td>
<td style="width: 1%;">:</td>
<td>
{{$p->nama_kategori_produk}}
</td>
</tr>
<tr>
<td style="width: 15%;"><b>Kategori Belanja</b></td>
<td style="width: 1%;">:</td>
<td>{{$p->kode}} - {{$p->kategori_belanja}}</td>
</tr>
<tr>
<td style="width: 15%;"><b>Pagu</b></td>
<td style="width: 1%;">:</td>
<td>{{$p->kegiatan}}-{{$p->output}}-{{$p->sub_output}}-{{$p->komponen}}-{{$p->sub_komponen}}-{{$p->mak}} {{$p->uraian_mak}}</td>
</tr>
<tr>
<td style="width: 15%;"><b>Pembayaran</b></td>
<td style="width: 1%;">:</td>
<td>{{$p->jenis_pembayaran}}</td>
</tr>
</table><br>
<div class="tab">
<button class="tablinks" onclick="openCity(event, 'Pesanan')" >Pesanan</button>
<button class="tablinks" onclick="openCity(event, 'Penawaran')" id="defaultOpen">Penawaran</button>
<button class="tablinks" onclick="openCity(event, 'Negosiasi')">Negosiasi</button>
</div>
<div id="Pesanan" class="tabcontent">
<div class="col-md-12">
<table class="table">
<thead>
<tr>
<th style="text-align: center; width: 25px;">Kode BMN</th>
<th style="text-align: center; width: 25px;">Nama Barang</th>
<th style="text-align: center; width: 1px;">Kuantitas</th>
<th style="text-align: center; width: 25px;">Satuan Ukuran</th>
<th style="text-align: center; width: 25px;">Kode Unit</th>
</tr>
</thead>
<tbody>
<tr id="addRow" >
<td class="col-xs-3" style="text-align: center;">{{$p->kode_bmn}}
</td>
<td class="col-xs-3" style="text-align: center;">{{$p->jenis_barang}}
</td>
<td class="col-xs-5" style="text-align: center;">{{$p->kuantitas}}
</td>
<td class="col-xs-5" style="text-align: center;">{{$p->satuan_ukuran}}
</td>
<td class="col-xs-5" style="text-align: center;">{{$p->kode_ruang}}
</td>
</tr>
</tbody>
</table>
<div class="col-md-1 pull-right"><br><br>
<button type="submit" class="btn btn-primary pull-right">Save</button>
</div>
</form>
</div>
</div>
<div id="Penawaran" class="tabcontent">
<div class="col-md-12">
<table class="table">
<thead>
<tr>
<th style="text-align: center; width: 20px;">Kode BMN</th>
<th style="text-align: center; width: 15px;">Nama Barang</th>
<th style="text-align: center; width: 5px;">Kuantitas</th>
<th style="text-align: center; width: 5px;">Satuan Ukuran</th>
<th style="text-align: center; width: 20px;">Kode Unit</th>
<th style="text-align: center; width: 5px;">Harga Satuan</th>
</tr>
</thead>
<tbody>
<tr id="addRow" >
<td class="col-xs-3" style="text-align: center;">{{$p->kode_bmn}}
</td>
<td class="col-xs-3" style="text-align: center;">{{$p->jenis_barang}}
</td>
<td class="col-xs-5" style="text-align: center;">{{$p->kuantitas}}
</td>
<td class="col-xs-5" style="text-align: center;">{{$p->satuan_ukuran}}
</td>
<td class="col-xs-5" style="text-align: center;">{{$p->kode_ruang}}
</td>
<td class="col-xs-3">
<input class="form-control " type="text" placeholder="Enter title" />
</td>
</tr>
</tbody>
</table>
<div class="col-md-1 pull-right"><br><br>
<button class="btn btn-primary pull-right">Save</button>
</div>
</div>
</div>
<div id="Negosiasi" class="tabcontent">
<table class="table">
<thead>
<tr>
<th style="text-align: center; width: 1px;">No</th>
<th style="text-align: center; width: 20px;">Kode BMN</th>
<th style="text-align: center; width: 15px;">Nama Barang</th>
<th style="text-align: center; width: 5px;">Kuantitas</th>
<th style="text-align: center; width: 5px;">Satuan Ukuran</th>
<th style="text-align: center; width: 20px;">Kode Unit</th>
<th style="text-align: center; width: 5px;">Harga Satuan</th>
<th style="text-align: center; width: 10px;">Negosiasi</th>
<th style="text-align: center; width: 5px;">Status Negosiasi</th>
</tr>
</thead>
#php $no = 1; #endphp
<tbody>
<tr id="addRow" >
<td>{{ $no++ }}</td>
<td style="text-align: center;">1010101008</td>
<td style="text-align: center;">meja</td>
<td style="text-align: center;">5</td>
<td style="text-align: center;">UNIT</td>
<td style="text-align: center;">10001</td>
<td style="text-align: center;">Rp50.000</td>
<td class="col-xs-3">
<input class="form-control " type="text" placeholder="Enter title" />
</td>
<td style="text-align: center;">
<i class="fas fa-thumbs-up" style="color: green;"></i>
<i class="fas fa-thumbs-down" style="color: red;"></i>
</td>
</tr>
</tbody>
</table>
<div class="col-md-1 pull-right"><br><br>
<button type="submit" class="btn btn-primary pull-right">Save</button>
</div>
</div>
#endif
How to?
How do you click on the 'submit bid' button to display the same ip list?
please help me
How to display 1 data if the same id and when clicked displays the same id in controller laravel
I'm a little confused on your table structure but you could try using the unique method of collections. Give this a try:
// added ->unique()
return view('paket/home_daftar_paket',['paket' => $paket, 'pesanan' => $pesanan->unique('id_paket')]);

php foreach loop repeat td's 2 times in a tr

I creating a PDF for print the address of users. I have the below HTML structure:
I have tried with the below code:
<?php $i=0; ?>
<tr valign="top">
foreach ($users as $user): ?>
<?php if ($i % 2 == 1) {?>
<tr valign="top">
<?php } ?>
But it's now work as expect.
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="48%" align="left" valign="top" style="padding:10px 10px 15px; font-size:14px; color:#333; font-family:Verdana, Geneva, sans-serif; border:1px solid #ccc;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%" height="25" valign="bottom">Name</td>
<td width="78%" valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom"> </td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom">Phone</td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
</table></td>
<td width="4%" align="left"> </td>
<td width="48%" align="left" style="padding:10px 10px 15px; font-size:14px; color:#333; font-family:Verdana, Geneva, sans-serif; border:1px solid #ccc;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%" height="25" valign="bottom">Name</td>
<td width="78%" valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom"> </td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom">Phone</td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
</table></td>
</tr>
<tr valign="top">
<td height="15" align="left"></td>
<td height="15" align="left"></td>
<td height="15" align="left"></td>
</tr>
</table>
In the abolve table I want to repeat the TD in each TR 2 times and added the blank TR after every TR.
The above HTML out should be the below image:
Could any one can help me out this.
If I get properly what you're looking for : I want to repeat in one TR repeat two TD
Then this code:
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
echo"<table>";
for ($i = 1; $i <= 10; $i++) {
if(($i % 2) == 1) // odd -> start TR
{ echo "<tr><td class=\"dark\">$i</td>"; }
else // even -> close TR
{ echo "<td class=\"red\">$i</td></tr><tr><td colspan=\"2\">whatever here</tr>"; }
}
echo"</table>";
?>
will give you this output :
<table>
<tr><td class="dark">1</td><td class="red">2</td></tr><tr><td colspan="2">whatever here</tr>
<tr><td class="dark">3</td><td class="red">4</td></tr><tr><td colspan="2">whatever here</tr>
<tr><td class="dark">5</td><td class="red">6</td></tr><tr><td colspan="2">whatever here</tr>
<tr><td class="dark">7</td><td class="red">8</td></tr><tr><td colspan="2">whatever here</tr>
<tr><td class="dark">9</td><td class="red">10</td></tr><tr><td colspan="2">whatever here</tr>
</table>
EDIT after you comment : added one 'blank' TR
Try below solution you missed out to close
<?php
$i=0;
foreach ($users as $user){
if ($i % 2 == 0) {?>
<tr valign="top">
<?php } ?>
<td width="48%" align="left" style="padding:10px 10px 15px; font-size:14px; color:#333; font-family:Verdana, Geneva, sans-serif; border:1px solid #ccc;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%" height="25" valign="bottom">Name</td>
<td width="78%" valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom"> </td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom">Phone</td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
</table></td>
<?php if ($i % 2 == 0) {?>
</tr>
<?php } }?>

WriteHTML is not working in mpdf, blank screen displays

I am trying to figure out the problem in this, but not able to. Query is proper, Result i am getting. If i echo $html i get result, but nothing for WriteHTML();
Here is my code
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include("connect.php");
$id = $_GET['id'];
include("mpdf/mpdf.php");
$mpdf=new mPDF('utf-8', 'A4');
$mpdf->debug = true;
$mpdf->useOnlyCoreFonts = true; // false is default
$mpdf->SetProtection(array());
$mpdf->SetTitle("My Company");
$mpdf->SetAuthor("MeAuthor");
$mpdf->SetWatermarkText("Demo");
$mpdf->showWatermarkText = false;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->SetDisplayMode('fullpage');
$s1 = "SELECT * FROM mytable WHERE cid=".$id."";
$sql = mysqli_query($con, $s1) or die (mysqli_error($con));
$row = mysqli_fetch_array($sql);
$html = '
<html>
<head>
<body>
<!--mpdf
<htmlpageheader name="myheader">
<table width="100%"><tr>
<td width="80%" style="text-align: center; font-size: 16pt;">Company Name<br>
<span style="font-size: 11pt;text-align: center;">Address 123, Lorel Ipsum, sdfsdf sdsdgsdg,</span><br>
<span style="font-size: 11pt;text-align:center;">sdfdsfdsf, sfsdf - 100066
</td>
</tr>
</table>
</htmlpageheader>
<sethtmlpageheader name="myheader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myfooter" value="off" />
mpdf-->
<table width="100%">
<tr><td colspan="2" align="right" width="40%"> Vocher No : '.$id.' </td></tr>
<tr>
<td width="70%">Debit A/C. : '.$row['account_no'].' </td>
<td width="30%" style="text-align: right">Date: '.date("d-m-Y").'</td></tr>
</table>
<div style="border: 1px solid black">
<table border="0" style="white-space:nowrap; border-spacing:0;" height="100%" cellspacing="5"><thead>
<tr>
<th width="30%" style="border-right:1px solid #000;">Name</th>
<th width="20%" style="border-right:1px solid #000;">E-Mail</th>
<th width="20%" style="border-right:1px solid #000;">Mobile</th>
<th width="30%" style="border-right:1px solid #000;">Particulars</th>
<th width="15%" style="border-right:1px solid #000;">RS.</th>
<th width="5%" style="border-right:1px solid #000;">P.</th>
</tr>
</thead>
<tr>
<td style="border-right:1px solid #000;" width="30%" height="100px;" >'.$row['name'].'</td>
<td style="border-right:1px solid #000;" width="20%">'.$row['email'].'</td>
<td style="border-right:1px solid #000;" width="20%">'.$row['mobile'].'</td>
<td style="border-right:1px solid #000;" width="30%">'.$row['purpose'].'</td>
<td style="border-right:1px solid #000;" width="15%">'.$row['amount'].'</td>
<td style="border-right:1px solid #000;" width="5%">00</td>
</tr>
<tr><td colspan="4" style="font-weight:bold;">Total Rs.</td> '.$row['amount'].'<td></tr>
</table></div>
<br>
<table border="0"><tr><td style="width=50%;">Mode of Payment : '.$row['mode'].' </td><td width="50%">Date : '.date('Y-m-d').'</td></tr>
<tr><td colspan="2">Rupees : </td></tr>
</table>
<br><br><br>
<table width="100%" border="0">
<tr><td width="20%"> Hon. Secretary </td>
<td width="20%">Hon. Treasurer</td>
<td width="20%">Hon. Trustee</td>
<td width="20%">Receiver s Signature</td></tr>
</table>
</body>
</html>
';
//echo $html;
echo $mpdf->WriteHTML($html);
//$mpdf->Output('Receipt.pdf','D');
$mpdf->Output();
?>
Method WriteHTML() returns void! So you'll not get any echo.
Note that you have not send anything to browser (even http-header) before Output().

HTMl Table's border not showing on Php PDF

Why do the borders of my tables not appear when I print my pdf to the screen?
I'm using the mPDF library.
I create the tables in html and for some reason it is not showing.
I already tried using inline CSS but it didn't work, for me.
<?php
require_once 'MPDF57\MPDF57\mpdf.php';
class TablePDF {
public function printPDF() {
$mpdf = new mPDF();
$border = 2 ;
$mpdf->SetHeader("Tabela");
$mpdf->SetFooter("Tabela");
$htmlpdf= "
<html>
<head>
<link type='text/css' rel=' rel='heet' href=' href='tstrap.min.css'>
<link type='text/css' rel='stylesheet' href='css/estilo.css'>
<style type='.text/css.'>
<title>Table</title>
</style>
.td{
style='border: 1px solid';
}
</head>
<body>
<table class='tabela' border=".$border." style='border:10px solid;'>
<tr style='border:10px solid black'>
<th width='150' style='border:10px solid black; '>GE</th>
<td width='200' style='border:10px solid black; '>0</td>
<td width='200' style='border:10px solid black; '><strong>Nome Curto</strong></td>
<td width='200' style='border:10px solid black; '>0</td>
</tr>
</table>
<table class='tabela' border=".$border." style='border:10px solid black'>
<tr>
<th width='150'>Valor</th>
<td width='200'>0</td>
<td width='200'><strong>FG</strong></td>
<td width='200'>0</td>
</tr>
</table>
<table class='tabela' border=".$border." style='border:10px solid black'>
<tr>
<th width='150'> Jugular </th>
<td width='117'>0</td>
<td width='117'>0</td>
<td width='117'>0</td>
<td width='118'>0</td>
<td width='119'>0</td>
</tr>
</table>
<table class='tabela' border=".$border." style='border:10px solid black'>
<tr>
<th width='150'>EXP3D</th>
<td width='200'>0</td>
<td width='200'>0</td>
<td width='200'>0</td>
</tr>
</table>
<table class='tabela' border=".$border." style='border:10px solid black'>
<tr>
<th width='150'>EXP28D</th>
<td width='200'>0</td>
<td width='200'>0</td>
<td width='200'>0</td>
</tr>
</table>
<table class='tabela' border=".$border." style='border:10px solid black'>
<tr>
<th width='150'>Carotida</th>
<td width='303'>0</td>
<td width='303'>0</td>
</tr>
</table>
</body>
</html>";
$mpdf -> useOnlyCoreFonts = true;
$mpdf->WriteHTML($htmlpdf);
$mpdf->Output();
}
}
?>
Then I use this to use this function to print the pdf:
<?php
require_once 'TablePDF.php';
$var = new TablePDF();
$var->printPDF();
?>
EDIT: the problem has been solved, i just started deleting the table class in the TABLE tag line because for some reason it wastn recognizing it as a class.
thanks alot folks.
td {
border: 1px solid;
}
You don't have to create style every time that you need to use a td in your page, you only call the style.

dompdf render doesn't look like html

i use dompdf with codeigniter to convert my php (html) file into pdf.
My problem is the dompdf render doesn't appear like my php page :
Style for php file :
body {font-family:Arial, Helvetica, sans-serif;
font-size:15px;
color:#000;}
.xls {
border-top:1px solid #868686; }
.xls tr > td {
border-right:1px solid #868686; padding: 2px 3px 2px 5px;}
.t-pad tr > td {
border-right:1px solid #868686; padding: 2px 3px 2px 5px;}
.xls tr:first-child >td {
border-top:1px solid #868686;border-bottom:1px solid #000;}
.xls tr:last-child >td {
border-bottom:1px solid #868686;
text-align: center;
}
.xls {
border-right:1px solid #868686;
border-left:1px solid #868686;
}
.xls .m-td{
border-bottom: 0 none !important;
border-left: 1px solid #868686;
border-right: 1px solid #868686;
border-top: 0 none !important;}
.last-col{border-right:0 !important;
border-top: 0 none !important; }
.td-tab{ padding:10px 10px 10px 20px !important;}
.tab-center{ border-left: 1px solid #868686; }
.tab-center td{ padding: 0 0 0 5px; border-bottom: 1px solid #868686; }
.first-td {
border-top: 1px solid #868686 !important;
}
.border-r{border-right: 1px solid #868686 !important;}
.tab-cc{
border: 1px solid #868686;
}
.border-bt{border-bottom: 1px solid #868686 !important;}
.titre-tab {
background:#b2b1b1;
}
and it appear like :
http://info-du-jour.net/wp-content/uploads/2014/06/php.png
fil in controller to convert into pdf :
$data = $this->data_paie($ids);
$this->load->view('paie/fdp_etat', $data);
// Get output html
$html = $this->output->get_output();
// Load library
$this->load->library('dompdf_gen');
// Convert to PDF
$this->dompdf->load_html($html);
$this->dompdf->render();
$this->dompdf->stream("fiche_de_paie.pdf",array('Attachment'=>0));
and it look like
http://info-du-jour.net/wp-content/uploads/2014/06/dompdf.png
html rendering code :
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="50" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="font-size:24px; font-weight:bold;">BULLETIN DE PAIE</td>
<td align="right">
<img src="/logo/logo_simple1.jpg"
width="136" height="31" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table cellspacing="0" cellpadding="0">
<tr>
<td colspan="3" width="101"><strong>Période :</strong></td>
<td width="197" colspan="3" align="center">
<div style="font-size:14px; font-weight:bold;">
01-06-2014 au 30-06-2014 </div>
</td>
</tr>
</table>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="48%" valign="top">
<table border="0" cellpadding="0" cellspacing="2" class="tab-cc t-pad" width="100%" style="height:150px;">
<tr>
<td width="137"><strong>Matricule</strong></td>
<td width="217">SAL003</td>
</tr>
<tr>
<td><b>Nom et Prénom</b></td>
<td>AYARI Marwa</td>
</tr>
<tr>
<td><strong>Fonction</strong></td>
<td>Développeur</td>
</tr>
<tr>
<td><strong>Sit. familiale</strong></td>
<td>Marié </td>
</tr>
<tr>
<td><strong>Nbre d'enfants</strong></td>
<td>3</td>
</tr>
</table></td>
<td width="4%"> </td>
<td width="48%" align="left" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="2" class="tab-cc" style="height:150px;">
<tr>
<td align="center"><b>EMPLOYEUR</b></td>
</tr>
<tr>
<td align="center"><strong>TOPO+</strong><br />
6 Rue des Cyclamens<br />
1004 EL MENZAH 5, ARIANA.<br />
CNSS Employeur : 45454 </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><table border="1" cellspacing="2" cellpadding="0" class="tab-cc xls" width="48%" >
<tr>
<td rowspan="2"><b>Droit congés payés</b></td>
<td align="center">Ancien solde</td>
<td align="center">(+) Droits</td>
<td align="center">(-) Pris</td>
<td align="center">Nouv. solde</td>
</tr>
<tr>
<td align="center">12</td>
<td align="center">1</td>
<td align="center">5</td>
<td align="center">2</td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<table width="100%" border="1" cellpadding="0" cellspacing="2" class="xls">
<tr class="titre-tab">
<td height="40"><strong>Désignation</strong></td>
<td><strong>Nombre</strong></td>
<td><strong>Base</strong></td>
<td><strong>Gains</strong></td>
<td><strong>Retenues</strong></td>
</tr>
<tr>
<td>Nombre de jours de présence</td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right">26</td>
<td align="right"> </td>
</tr>
<tr>
<td>Salaire de base</td>
<td align="right"> </td>
<td align="right">1258,799</td>
<td align="right">1258,799</td>
<td align="right"> </td>
</tr>
<!-- autant de lignes que de primes dans la conv collective -->
<tr>
<td>Indemnité de transport</td>
<td align="right"> </td>
<td align="right">40,000</td>
<td align="right">40,000</td>
<td align="right"> </td>
</tr>
<tr>
<td>Prime de présence</td>
<td align="right"> </td>
<td align="right">2,080</td>
<td align="right">2,080</td>
<td align="right"> </td>
</tr>
<tr>
<td>Indemnité de déplacement</td>
<td align="right"> </td>
<td align="right">0,000</td>
<td align="right">0,000</td>
<td align="right"> </td>
</tr>
<tr>
<td> <b>Total Brut</b></td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right">1300,879</td>
<td align="right"> </td>
</tr>
<tr>
<td>Retenu C.N.S.S</td>
<td align="right"> </td>
<td align="right">1300,879</td>
<td align="right"> </td>
<td align="right">119,421</td>
</tr>
<tr>
<td><b>SALAIRE IMPOSABLE</b></td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right">1181,458</td>
</tr>
<tr>
<td>IRPP</td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right">173,646</td>
</tr>
<tr>
<td> <b>Total Cotisations</b></td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right">293,067</td>
</tr>
<tr height="35">
<td> </td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td><table cellpadding="0" cellspacing="2" border="0" width="100%">
<tbody>
<tr height="21">
<td align="right"> </td>
<td></td>
<td></td>
<td></td>
</tr>
<tr height="21">
<td width="66%" align="right"><strong>Net à Payer</strong></td>
<td width="3%"></td>
<td width="2%"></td>
<td width="29%" colspan="2" align="right" class="tab-cc"><span style="font-weight:bold;padding-right: 4px;">1007,812</span> </td>
</tr>
<tr height="21">
<td align="right"> </td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
Instead of using $html = $this->output->get_output(); you can get the same HTML as it is rendering on browser . for that you need to make changes in script like :
$html = $this->load->view('paie/fdp_etat', $data , true); // so now your `$html` will be string which will return string from your view and both will be same.
For reference SEE HERE

Categories