Keep header and footer DOCX to PDF PHPWord/DOMPDF

After many tries and and researches, I still can’t get the header and footer of my docx file after the conversion to PDF. I read many topics and looked at the issue on the github forum but didn’t find what I needed. I also tried with TCPDF and same result.

        $domPdfPath = base_path('vendor/dompdf/dompdf'); Settings::setPdfRendererPath($domPdfPath);
Settings::setPdfRendererName('DomPDF');
$template = new TemplateProcessor(public_path('word-template/file.docx'));$saveDocPath = public_path('file.docx');
$template->saveAs($saveDocPath);

$Content = IOFactory::load($saveDocPath);

$savePdfPath = public_path('file.pdf'); if ( file_exists($savePdfPath) ) {
unlink($savePdfPath); }$PDFWriter = IOFactory::createWriter($Content,'PDF');$PDFWriter->save(\$savePdfPath);


Source: Laravel