Search code examples
phplaravelpdflaravel-5wkhtmltopdf

Laravel 5 PDF footers with blade show blank


I use "barryvdh/laravel-snappy": "^0.4.0"

for export pdf.

I want to add footer on my pdf file but when I add footer-html on my code show me blank pdf file.

public function exportPdf($id)
{
     $pdf = PDF::loadView('TestView::pdf', [my_array]);
     $pdf->setOption('footer-html', View('TestView::pdf_footer'));
     $pdf->setOrientation('landscape');
     $pdf->setPaper('a6');
}

And when I comment this code $pdf->setOption('footer-html', View('TestView::pdf_footer')); show me correct export pdf file.

TestView::pdf_footer content:

<footer class="footer">
     <div class="u-pattern"></div>
     <div class="u-back-green"></div>
</footer>

Solution

  • Your Footer needs to be a complete HTML file, otherwise wkhtmltopdf will not render it correctly.

    <!DOCTYPE html>
    <html>
    <head></head>
    <body>
        <footer class="footer">
            <div class="u-pattern"></div>
            <div class="u-back-green"></div>
        </footer>
    </body>
    </html>