wkhtmltopdf: why can not header & footer display in one pdf?

476 Views Asked by At

i use "knp_snappy.pdf" with php to create the pdf file.

$template = $this->renderView('DemoProductBundle:pdf:template.html.twig', array('productData' => $productData));
    $headerTemplate = $this->renderView('DemoProductBundle:pdf:header.html.twig');
    $footerTemplate = $this->renderView('DemoProductBundle:pdf:footer.html.twig');
    $knpSnappy = $this->get('knp_snappy.pdf');
    return new Response($knpSnappy->getOutputFromHtml($template, array(
        'page-size' => 'A4',
        'header-html' => $headerTemplate,
        'footer-html' => $footerTemplate,
        'margin-top' => '0'
    )),
        200,
        array(
            'Content-Type'          => 'application/pdf',
            'Content-Disposition'   => 'attachment; filename="file.pdf"'
        )
    );

the header content can display above main content, but the footer content cannot dispaly. but if i use AI software open this pdf file, i can found the footer content below the board. what's wrong with my code? another question, if i try to create multiple pdf files, the position of main content will be changed.

0

There are 0 best solutions below