'I am using PHP Chrome HTML 2 PDF but unable to use Header and Footer in the PDF

Please find the below code:

<?php
use Spiritix\Html2Pdf\Converter;
use Spiritix\Html2Pdf\Input\StringInput;
use Spiritix\Html2Pdf\Output\DownloadOutput;
require_once 'vendor/autoload.php';
$html="<p>This is the Content</p>";
$input = new StringInput();
$input->setHtml($html);

$converter = new Converter($input, new DownloadOutput());

$converter->setOption('landscape', false);
$converter->setOption('displayHeaderFooter', true);
$converter->setOption('headerTemplate', '<p>Header Here</p>');
$converter->setOption('footerTemplate', '<p>Footer Here</p>');

$output = $converter->convert();
$output->download('SOL-'.date('Y-m-d-h-i-s').'.pdf');
?>

The above code is working fine except the Header and Footer part. Header and Footer is not showing in the PDF. Please provide some suggestion to solve this issue.

Followed the below link for reference:

https://github.com/spiritix/php-chrome-html2pdf



Solution 1:[1]

I got the same problem and i found a solution here: https://github.com/spiritix/php-chrome-html2pdf/issues/9

The main content overlays the header and footer so you have to set margins on your page in order to let your header ad footer to pop out....

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1