Hi every body i have to make an invoice pdf in my LARAVEL project.
I succeeed to generate a pdf with this code :
$path_name_file = '../ArchivePdf/'. $name_file . '.pdf';
if ($document->type->type == 'A'){
$pdf = SnappyPdf::loadView('ribbon.report.pdf-achat', ['document' =>$document])
->save($path_name_file);
}else{
$pdf = SnappyPdf::loadView('ribbon.report.pdf-new', ['document' =>$document])->save($path_name_file);
}
My problem is in the blade view (HTML template) that i want to put an header and a footer and a main table with items
I want that the footer will be on all pages
How can i do that?
Thanks
That is my actual html view:
<!DOCTYPE html>
<html>
<header>
<meta charset="utf-8">
<title>PDF Devis</title>
{{--<link href="{{ asset("/css/style_pdf.css")}}" rel="stylesheet" type="text/css" />--}}
<style>
.header-1{
border-top-left-radius: 7px;
border-top-right-radius: 7px;
/*left: 5%;*/
width: 100%;
border-style: solid;
font-size: 13px;
border-width: 2px;
}
th {
background-color: rgba(158, 158, 158, 0.22);
text-align: center;
}
.line{
width: 100%;
}
.line tr{
padding: 0;
}
.td-20{
width:20%
}
.td-30{
width:30%
}
.td-70{
width: 70%;
}
.td-40{
width: 40%;
}
.td-50{
width: 50%;
}
.img img{
width:100%; height:auto;
}
.name-soc{
font-size: 25px;
color: orangered;
direction: rtl;
font-family: arial;
font-style: bold;
}
.space{
padding-top: 20px;
}
.title{
font-weight: bold;
height: 50px;
color: white;
background-color: rgba(255, 87, 34, 0.89);
font-size: 25px;
border-radius: 5px;
bottom: 15px;
text-align: center;
}
.items{
}
.more_line{
height: 17px;
}
/*.items-table{*/
/*page-break-after: always;*/
/*page-break-inside: avoid;*/
/*}*/
thead { display: table-header-group }
tfoot { display: table-row-group }
.items-row { page-break-inside: avoid }
table { border-collapse: separate }
.note-table{
text-align: right;
width: 100%;
}
</style>
</header>
<body>
<table class="line">
<tr>
<td rowspan="4" class="td-30">
<div class="img"> <img src="{{ public_path('/ribbon/pdf/fre.jpg') }}" alt="logo"/></div>
</td>
<td class="td-30">
<div></div>
</td>
<td class="td-40">
<div class="name-soc">
דקופלוס פרקט בע״מ
</div>
</td>
</tr>
<tr>
<td class="td-30">
<div></div>
</td>
<td class="td-40">
<div class="name-soc">
</div>
</td>
</tr>
<tr>
<td class="td-20">
<div></div>
</td>
<td class="td-20">
<div></div>
</td>
</tr>
<tr>
<td class="td-20">
<div></div>
</td>
<td class="td-20">
<div></div>
</td>
</tr>
</table>
<table class="line">
<tr class="entete">
<td class="logo">
</td>
<td class="donnee_soc">
<div dir="rtl">{{trans('dcp_pdf.num_doc')}} : {{ $document->code }} </div>
</td>
</tr>
<tr>
<td class="td-50">
<div>
<table class="header-1" dir="rtl">
<tr>
<th colspan="2">{{trans('dcp_pdf.coord_cust')}}</th>
</tr>
<tr class="" >
<td>
<div style="width: 20%">{{trans('dcp_pdf.name')}}</div>
</td>
<td>
<div class="encadre_data">{{ $document['customer']['name'] }} {{ $document['customer']['surname'] }}</div>
</td>
</tr>
<tr class="" >
<td>
<div style="width: 20%">{{trans('dcp_pdf.adress')}}</div>
</td>
<td>
<div class="encadre_data">{{ $document['adress']['street'] }} {{ $document->adress->city->cityT[0]->texte }}</div>
</td>
</tr>
<tr class="" >
<td>
<div style="width: 20%">{{trans('dcp_pdf.telephone')}}</div>
</td>
<td>
<div class="encadre_data">{{ $document['customer']['phone'] }} / {{ $document['customer']['phone2'] }}</div>
</td>
</tr>
<tr class="" >
<td>
<div style="width: 20%">{{trans('dcp_pdf.mail')}}</div>
</td>
<td>
<div class="encadre_data">{{ $document['customer']['email'] }}</div>
</td>
</tr>
</table>
</div>
</td>
<td class="td-50">
<div>
<table class="header-1" dir="rtl">
<tr>
<th colspan="2">{{trans('dcp_pdf.coord_fact')}}</th>
</tr>
<tr class="" >
<td>
<div style="width: 20%">{{trans('dcp_pdf.name')}}</div>
</td>
<td>
<div class="encadre_data">{{ $document['customer']['name'] }} {{ $document['customer']['surname'] }}</div>
</td>
</tr>
<tr class="" >
<td>
<div style="width: 20%">{{trans('dcp_pdf.adress')}}</div>
</td>
<td>
<div class="encadre_data">{{ $document['adress']['street'] }} {{ $document->adress->city->cityT[0]->texte }}</div>
</td>
</tr>
<tr class="" >
<td>
<div style="width: 20%">{{trans('dcp_pdf.telephone')}}</div>
</td>
<td>
<div class="encadre_data">{{ $document['customer']['phone'] }} / {{ $document['customer']['phone2'] }}</div>
</td>
</tr>
<tr class="" >
<td>
<div style="width: 20%">{{trans('dcp_pdf.mail')}}</div>
</td>
<td>
<div class="encadre_data">{{ $document['customer']['email'] }}</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr >
<td colspan="2" class="space">
<div>
<table class="header-1" dir="rtl">
<tr>
<th colspan="2">{{trans('dcp_pdf.coord_livraison')}}</th>
</tr>
<tr class="" >
<td>
<div style="width: 20%">{{trans('dcp_pdf.name')}}</div>
</td>
<td>
<div class="encadre_data">{{ $document['customer']['name'] }} {{ $document['customer']['surname'] }}</div>
</td>
</tr>
<tr class="" >
<td>
<div style="width: 20%">{{trans('dcp_pdf.adress')}}</div>
</td>
<td>
<div class="encadre_data">{{ $document['adress']['street'] }} {{ $document->adress->city->cityT[0]->texte }}</div>
</td>
</tr>
<tr class="" >
<td>
<div style="width: 20%">{{trans('dcp_pdf.telephone')}}</div>
</td>
<td>
<div class="encadre_data">{{ $document['customer']['phone'] }} / {{ $document['customer']['phone2'] }}</div>
</td>
</tr>
<tr class="" >
<td>
<div style="width: 20%">{{trans('dcp_pdf.mail')}}</div>
</td>
<td>
<div class="encadre_data">{{ $document['customer']['email'] }}</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr >
<td colspan="2" class="space">
<div class="title" dir="rtl">
{{ $document->type->typeT[0]->texte }} - {{ $document->code }}
</div>
</td>
</tr>
<tr >
<td colspan="2" class="space">
<table class="items header-1 items-table" dir="rtl">
<thead>
<tr class="more_line">
<th class="Désignation" >{{trans('dcp_pdf.desc_article')}}</th>
<th class="other">{{trans('dcp_pdf.conditionnement')}}</th>
<th class="other">{{trans('dcp_pdf.quantity_m2')}}</th>
<th class="other">{{trans('dcp_pdf.nb_colis')}}</th>
<th class="other">{{trans('dcp_pdf.pu_ht')}}</th>
<th class="other">{{trans('dcp_pdf.discount')}}</th>
<th class="other">{{trans('dcp_pdf.total_ht')}}</th>
</tr>
</thead>
#foreach($document->items as $item)
<tr class="1 items-row">
<td class="Designation" dir="rtl"><div dir="rtl">{{ $item->material->textes[0]->texte }}</div></td>
<td class="Cdt"></td>
<td class="Qtem2">{{ $item->quantity }}</td>
<td class="Nb_colis">{{ $item->qte_col }}</td>
<td class="PU">{{ number_format($item->price, 2, '.', ',') }}</td>
<td class="Rem">{{ number_format($item->discount, 2, '.', ',') }} {{ $item->typeRemise->code }}</td>
<td class="Total"> {{ number_format($item->price_wo_vat, 2, '.', ',') }}</td>
</tr>
#endforeach
#for ($i = $document->items->count(); $i < 20; $i++)
<tr class="more_line">
<td class="Designation" dir="rtl"><div dir="rtl"></div></td>
<td class="Cdt"></td>
<td class="Qtem2"></td>
<td class="Nb_colis"></td>
<td class="PU"></td>
<td class="Rem"></td>
<td class="Total"></td>
</tr>
#endfor
</table>
</td>
</tr>
<tr >
<td colspan="2" >
<table class="note-table" dir="rtl">
<tr class="" >
<td>
<div class="encadre_data">{{ $document['note'] }} </div>
</td>
</tr>
<tr class="" >
<td >
<div class="encadre_data">{{ $document['comment'] }} </div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="td-30">
<div>
<table class="header-1" dir="rtl">
<tr>
<td>{{trans('dcp_pdf.montant_ht')}}</td>
<td>{{ number_format($document->amount_wo_taxe, 2, '.', ',') }}</td>
</tr>
<tr>
<td>{{trans('dcp_pdf.dont_remise')}}</td>
<td></td>
</tr>
#if ($document['customer']['code_tva'] === 1)
<tr>
<td>{{trans('dcp_pdf.tva')}} {{ number_format($document->taxe, 2, '.', ',') }} %</td>
<td>{{ number_format($document->amount - $document->amount_wo_taxe, 2, '.', ',') }}</td>
</tr>
#endif
<tr>
<td>{{trans('dcp_pdf.montant_ttc')}}</td>
<td>{{ number_format($document->amount, 2, '.', ',') }}</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
</div>
</td>
<td class="td-70">
<div>
<table class="header-1" dir="rtl">
<tr>
<th colspan="4">{{trans('dcp_pdf.reglements')}}</th>
</tr>
<tr>
<th>{{trans('dcp_pdf.date')}}</th>
<th>{{trans('dcp_pdf.description')}}</th>
<th>{{trans('dcp_pdf.montant')}}</th>
<th>{{trans('dcp_pdf.mode_paiement')}}</th>
</tr>
#foreach($document->reglements as $reglement)
<tr>
<td>{{ $reglement->date }}</td>
<td>{{ $reglement->description }}</td>
<td>{{ number_format($reglement->amount, 2, '.', ',') }}</td>
<td>{{ $reglement->mode->modePaiementT[0]->texte }}</td>
</tr>
#endforeach
</table>
</div>
</td>
</tr>
<tr>
<td>
<div></div>
</td>
<td>
<div></div>
</td>
</tr>
<tr>
<td>
<div></div>
</td>
<td>
<div></div>
</td>
</tr>
<tr>
<td>
<div></div>
</td>
<td>
<div></div>
</td>
</tr>
<tr>
<td>
<div></div>
</td>
<td>
<div></div>
</td>
</tr>
<tr>
<td>
<div></div>
</td>
<td>
<div></div>
</td>
</tr>
</table>
</body>
</html>
Here is the documentation about header and footer with Wkhtmltopdf support.
You can try
For Header
setOption('header-html', 'Your Header');
For Footer
setOption('footer-html', 'Your Footer');
Just make sure that you need to add <!DOCTYPE HTML><html lang='en-US'> in the beginning of your header/footer HTML!
Related
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')]);
I use laravel-dompdf to generate pdf from view. Everything works fine except the "text-align: center" CSS.
It aligns to the center, but a little bit "offset" to the right.
Here's the sample PDF output
As you can see the "FOTO JAMINAN", "as", "no rek", and "FOTO PERIKATAN" text are a little bit offset to the right.
Here's the view
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<style>
.table1 {
font-family: sans-serif;
color: #232323;
border-collapse: collapse;
}
.table1,
th,
td {
border: 1px solid #999;
padding: 8px;
width: 300px;
}
.judul {
text-align: center;
background-color: blue;
color: #ffffff;
}
</style>
</head>
<body>
<h2>Detail Data Lampiran Foto Jaminan BPKB dan Perikatan</h2>
<table style="width: 100%;">
<tr>
<td class="judul" colspan="2">FOTO JAMINAN</td>
</tr>
<tr>
<td colspan="2"><center>{{ $datafotobpkb->atasNama }}</center></td>
</tr>
<tr>
<td colspan="2">
<center>
{{ $datafotobpkb->noRekening }}
</center>
</td>
</tr>
<tr>
<td>
<center>
#if($datafotobpkb->pathJaminanAsli1 !== null)
<img width="300" src="{{url($datafotobpkb->pathJaminanAsli1)}}">
#endif
</center>
</td>
<td>
<center>
#if($datafotobpkb->pathJaminanAsli2 !== null)
<img width="300" src="{{url($datafotobpkb->pathJaminanAsli2)}}">
#endif
</center>
</td>
</tr>
<tr>
<td>
<center>
#if($datafotobpkb->pathJaminanAsli3 !== null)
<img width="300" src="{{url($datafotobpkb->pathJaminanAsli3)}}">
#endif
</center>
</td>
<td>
<center>
#if($datafotobpkb->pathJaminanAsli4 !== null)
<img width="300" src="{{url($datafotobpkb->pathJaminanAsli4)}}">
#endif
</center>
</td>
</tr>
<tr>
<td>
<center>
#if($datafotobpkb->pathJaminanAsli5 !== null)
<img width="300" src="{{url($datafotobpkb->pathJaminanAsli5)}}">
#endif
</center>
</td>
<td>
<center>
#if($datafotobpkb->pathJaminanAsli6 !== null)
<img width="300" src="{{url($datafotobpkb->pathJaminanAsli6)}}">
#endif
</center>
</td>
</tr>
<tr>
<td colspan="2" rowspan="3">
{{ $datafotobpkb->rincianAgunan }}
</td>
</tr>
</table>
<table style="width: 100%;">
<tr>
<td colspan="2" class="judul">
<center>
FOTO PERIKATAN
</center>
</td>
</tr>
<tr>
<td>
<center>
#if($datafotobpkb->pathPerikatanAsli1 !== null)
<img width="300" src="{{url($datafotobpkb->pathPerikatanAsli1)}}">
#endif
</center>
</td>
<td>
<center>
#if($datafotobpkb->pathPerikatanAsli2 !== null)
<img width="300" src="{{url($datafotobpkb->pathPerikatanAsli2)}}">
#endif
</center>
</td>
</tr>
<tr>
<td>
<center>
#if($datafotobpkb->pathPerikatanAsli3 !== null)
<img width="300" src="{{url($datafotobpkb->pathPerikatanAsli3)}}">
#endif
</center>
</td>
<td>
<center>
#if($datafotobpkb->pathPerikatanAsli4 !== null)
<img width="300" src="{{url($datafotobpkb->pathPerikatanAsli4)}}">
#endif
</center>
</td>
</tr>
<tr>
<td colspan="2">
{{ $datafotobpkb->atasNama }}
</td>
</tr>
<tr>
<td colspan="2">
{{ $datafotobpkb->noRekening }}
</td>
</tr>
<tr>
<td colspan="2">
Pokok Hutang:{{ $datafotobpkb->pokokHutang }} / Jangka Waktu : {{ $datafotobpkb->jangkaWaktu }} / Jasa :
{{ $datafotobpkb->jasa }}
</td>
</tr>
<tr>
<td colspan="2">
Tanggal Perikatan:{{ $datafotobpkb->tglPerikatan }}
</td>
</tr>
</table>
</div>
</body>
</html>
And here's the controller function
public function cetak_pdf($id)
{
$datafotobpkb = Datafotobpkb::find($id);
if($datafotobpkb === null)
{
abort(404);
}
$this->check_priviledge($datafotobpkb);
$pdf = PDF::loadview('datafotobpkb.datafotobpkb_pdf',['datafotobpkb'=>$datafotobpkb]);
// return $pdf->download('datafotobpkb-'.date('Y-m-d-h-i').'.pdf');
return $pdf->stream('datafotobpkb-'.date('Y-m-d-h-i').'.pdf');
}
Any idea how to fix this? Thanks in advance.
There were two options if you wanna still use same library Barryvdh\DomPDF\Facade::class . Tested and work well
For center-align, display-block solution
<p style="display: block; margin-left: auto; margin-right: auto; font-size: 16px; text-align: center;">
...
</p>
use floating
<div>
<div style="float:left; font-size: 20px; font-weight: bold">
...
</div>
<div style="float:right; font-size: 20px; font-weight: bold">
...
</div>
</div>
I went through the same problem today. I resolved by updating the version from "barryvdh/laravel-dompdf": "^0.8.4", to "barryvdh/laravel-dompdf": "^0.8.5".
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.
I'm not the best at explaining things but here I go,
On a different site, I have 10 elements that i want to get and assign to variables
this is how they are
element 1:
<div class="username_header dynamic_fontsize" style="font-size: 48px; top: 0px;">
<span class="username">[element 1]</span>
<span class="user_online_msg">stuff</span>
</div>
elements 2-10
<div class="forum_profile_right_block">
<table border="0" width="97%" cellspacing="2" cellpadding="5">
<tbody>
<tr>
<td>
<div style="font-color:black; font-size:1em">abc2</div>
</td>
<td colspan="2" align="center" bgcolor="#F0F0F0">[element 2]</td>
</tr>
<tr>
<td>
<div style="font-color:black; font-size:1em">abc34</div>
</td>
<td align="center" bgcolor="#F0F0F0">[element 3]</td>
<td align="center" bgcolor="#F0F0F0">[element 4]</td>
</tr>
<tr>
<td>
<div style="font-color:black; font-size:1em">abc5</div>
</td>
<td colspan="2" align="center" bgcolor="#F0F0F0">[element 5]</td>
</tr>
<tr>
<td>
<div style="font-color:black; font-size:1em">abc6</div>
</td>
<td colspan="2" align="center" bgcolor="#F0F0F0">[element 6]
</td>
</tr>
<tr>
<td>
<div style="font-color:black; font-size:1em">abc7</div>
</td>
<td colspan="2" align="center" bgcolor="#F0F0F0">[element 7]</td>
</tr>
<tr>
<td>
<div style="font-color:black; font-size:1em">abc8</div>
</td>
<td colspan="2" align="center" bgcolor="#F0F0F0">[element 8]</td>
</tr>
<tr>
<td>
<div style="font-color:black; font-size:1em">abc9</div>
</td>
<td colspan="2" align="center" bgcolor="#F0F0F0">
<div style="display:inline-block;">[element 9]</div>
<div style="display: inline-block; position: relative; top: 1px;"><img src="images/msdropdown/icons/blank.gif" class="flag us"></div>
</td>
</tr>
<tr>
<td>
<div style="font-color:black; font-size:1em">abc10</div>
</td>
<td colspan="2" align="center" bgcolor="#F0F0F0">[element 10]
</td>
</tr>
</tbody>
</table>
<br>
</div>
I'm using Laravel to create a PDF report that has a big table which has 3 other tables nested inside for the sake of side-by-side viewing. I know domPDF won't support Floating so I had to do this. I couldn't also use Positioning since there will be repeatations of the same element on page so this seemed like the best idea.
However, whenever I have multiple nested tables in PDF, this weird thing happens:
I have been able to find any solutions to this online.
Source Code:
#foreach ($employees as $employee)
<table style="width: 100%; margin-top: 5px; border-bottom: 1px solid grey; margin-bottom: 5px;" border="0" cellspacing="0" cellpadding="5">
<tbody>
<tr>
<td width="25%" style="background: lightgrey;">Name: <strong>{{$employee['info']->name}}</strong></td>
<td width="25%" style="background: lightgrey;">Mobile: <strong>{{$employee['info']->mobile}}</strong></td>
<td width="25%">Date: <strong>{{$inputs['date']}}</strong></td>
<td width="25%">Remarks:</td>
</tr>
<tr>
<td colspan="2">
<table style="width: 100%;" border="1" cellpadding="5" cellspacing="0">
<thead>
<tr>
<th colspan="3">Receive</th>
</tr>
</thead>
<tbody>
#if ($employee['given']->isEmpty())
<tr>
<td colspan="2"></td>
</tr>
#else
#foreach ($employee['given'] as $tr)
<tr>
<td>{{ strtoupper($tr->category) }}</td>
<td style="text-align: right;">{{ App\Transaction::formatMoney($tr->amount) }}</td>
</tr>
#endforeach
#endif
</tbody>
</table>
</td>
<td colspan="2">
<table style="width: 100%;" border="1" cellpadding="5" cellspacing="0">
<thead>
<tr>
<th colspan="3">Return</th>
</tr>
</thead>
<tbody>
#if ($employee['returned']->isEmpty())
<tr>
<td colspan="2"></td>
</tr>
#else
#foreach ($employee['returned'] as $tr)
<tr>
<td>{{ strtoupper($tr->category) }}</td>
<td style="text-align: right;">{{ App\Transaction::formatMoney($tr->amount) }}</td>
</tr>
#endforeach
#endif
</tbody>
</table>
</td>
</tr>
<tr>
<td>
<table style="width:100%" border="1" cellpadding="2" cellspacing="0">
<tbody>
<tr>
<td>Total Receive</td>
<td style="text-align: right;">{{ App\Transaction::formatMoney($employee['given']->sum('amount')) }}</td>
</tr>
<tr>
<td>Total Return</td>
<td style="text-align: right;">{{ App\Transaction::formatMoney($employee['returned']->sum('amount')) }}</td>
</tr>
<tr style="background-color: {{ $employee['returned']->sum('amount') - $employee['given']->sum('amount') < 0 ? 'lightgrey' : '' }}">
<td>Balance</td>
<td style="text-align: right;">{{ App\Transaction::formatMoney($employee['returned']->sum('amount') - $employee['given']->sum('amount')) }}</td>
</tr>
<tr>
<td>B2B</td>
<td style="text-align: right;">{{ App\Transaction::formatMoney($employee['b2b']) }}</td>
</tr>
<tr>
<td>Sale</td>
<td style="text-align: right;">{{ App\Transaction::formatMoney($employee['sale']) }}</td>
</tr>
</tbody>
</table>
</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
#endforeach
It looks like your table headers ("Receive" and "Return") are set to colspan="3" while the actual number of columns in that table are only 2. It's obviously some buggy behavior around rendering the table, but if you set the colspan to 2 it should render as expected.