Export Word - add a header

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
Cat
User
Posts: 78

Export Word - add a header

Post by Cat »

hello everyone

I need to add a header when exporting to Word

this code fails

any ideas

function pageExporting(&$doc)
    {
    $phpWord = new \PhpOffice\PhpWord\PhpWord();
    $section = $phpWord->addSection();
    $header = $section->addHeader();
    $header->firstPage();
    // Agregar contenido al encabezado utilizando los métodos de PhpWord
    $header->addText("<center>IS-FT-014 Versión:0</center>");
    $header->addText("<font size=8><center><b>INFORME </b></center></font>");
        return true; // Return true to use default export and skip Row_Export event
     }

arbei
User
Posts: 9384

Post by arbei »

Your code does something itself without using the $doc argument at all. You should use $doc->PhpWord to get the PhpWord instance.


Cat
User
Posts: 78

Post by Cat »

in page_exporting function

I was able to customize a header in the export to Word with the phpword extension

but it no longer allows exporting to pdf, there is a JSON error


arbei
User
Posts: 9384

Post by arbei »

You may post your code for discussion.


Post Reply