如何使用laravel 4中的wkhtmltopdf将页脚html添加到从视图刀片生成的pdf中

时间:2014-01-12 18:32:29

标签: php laravel-4 wkhtmltopdf

我是Laravel 4的新手。我正在使用wkhtmltopdf从我的view.blade.php文件生成PDF。我需要在PDF的页脚添加footer.blade.php。我该怎么做?

这是我的控制器功能,用于生成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;
}

这是我的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

当我下载PDF时,页脚不会出现..

1 个答案:

答案 0 :(得分:1)

尝试使用:

@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">
...

我使用DOMPDF和Laravel,它对我有用