set background for wkhtmltopdf

724 Views Asked by At

I have a background image template

enter image description here

where header and footer is in the template image I just want to render content in content area

how to achieve this?

I tried to separate the header and footer html and my code sample is my php code is

$html = view('products.pdf.index', compact('product'))->render();

    $pdf = PDF::loadHTML($html)
        ->setPaper('a4')
        ->setOrientation('portrait')
        ->setOption('header-spacing', 0)
        ->setOption('footer-spacing', 0)
        ->setOption('header-html', view('products.pdf.header')->render())
        ->setOption('footer-html', view('products.pdf.footer')->render())
        ->setOption('margin-top', 10)
        ->setOption('margin-right', 0)
        ->setOption('margin-bottom', 18)
        ->setOption('margin-left', 0);
    return $pdf->download($product->title . '.pdf');

where in header(products.pdf.header) file I have header content and in footer(products.pdf.footer) file I have footer content, $html holds my content

0

There are 0 best solutions below