HimanshuSamantaray
HimanshuSamantaray

Reputation: 93

how to add a footer html to a pdf generated from the view blade using wkhtmltopdf in laravel 4

I am new to Laravel 4. I am using wkhtmltopdf for generating a PDF from my view.blade.php file. I need to add footer.blade.php at the footer of the PDF. How should I do this?

Here is my controller function to generate PDF:

public function generatePdf($werkbon_id)
{
    //Generate name for the pdf file
    $pdf_name = md5(time()).".pdf";

    //Get the path of werkbon view with $generatePdf set to 1
    $url    = route('generateWerkbon', array($werkbon_id, 1));

    //Get the path of werkbon pdf
    $path   = public_path(). '/werkbons/' . $pdf_name;

    //Get the path of footer.html
    $footer_path = route('footerPath');

    //Command to generate pdf from html using wkhtmltopdf
    $cmd = "c:\wkhtmltopdf\wkhtmltopdf -B 20mm --footer.html " . "$footer_path $url $path";
    //echo $cmd;exit;
    //Execute the command
    exec($cmd);

    //Return name of the pdf file
    return $pdf_name;
}

Here is my footer.blade.php:

@extends('layouts.footer')

@section('head')
   <title>Footer Path</title>
@stop

@section('content')
<body>
    <div>
        <span >RABOBANK XX.XX.XX.XX - IBAN:NL XX RABO XXXXXXXXXX . K.v.K. Leiden XXXXXXXX . BTW nr. NLXXXXXXXXXXX</span>
        <br>
        <br>
        <span style = "color:#068EF4;font-size:13px;font-family:font-family: ArialMT !important;">Op al onze offertes , op alle opdrachten aan ons en op alle met ons gesloten overeenkomsten zijn de METAALUNIEVOORWAARDEN 
        van toepassing ,<br>zoals deze luiden volgens de op de achterzijde afgedrukte tekst.De leveringsvoorwaarden worden u,indien gewenst 
        tevens kosteloos toegezonden</span>
    </div>

</body>
@stop

When I download the PDF, the footer is not coming..

Upvotes: 0

Views: 1900

Answers (1)

Laura Chesches
Laura Chesches

Reputation: 2583

try to use :

@extends('layouts.footer')

@section('head')
   <title>Footer Path</title>
    <style type="text/css">        
       .footer {
            position: fixed;
            bottom: 50px; // or how low do you want it
        }
   </style>
@stop

@section('content')
<body>
    <div class="footer">
...

i use DOMPDF and Laravel and it worked for me

Upvotes: 1

Related Questions