Keep header and footer DOCX to PDF PHPWord/DOMPDF

  dompdf, laravel, phpword

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');
        $template = new TemplateProcessor(public_path('word-template/file.docx'));   

        $saveDocPath = public_path('file.docx');

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

        $savePdfPath = public_path('file.pdf');

        if ( file_exists($savePdfPath) ) {

        $PDFWriter = IOFactory::createWriter($Content,'PDF');           

Source: Laravel

Leave a Reply