Search code examples
phpdocphpword

How to stretch the footer to the full width of the page using phpword?


I use PHPWord to generate a document. How can I remove the indent on the left side for the footer, so that it occupies the entire width?

For header, I use:

$header = $section->addHeader();
        $header->addImage('images/header.png',
            array(
                'width'=>600,
                'height'=>72,
                'marginLeft' => -75,
                'positioning'=>'absolute',
                'wrappingStyle'=> 'behind',
                'posHorizontal' => 'absolute',
                'posVertical' => 'absolute'
            ));

but for footer it doesn't work.

$footer = $section->addFooter();
        $footer->addImage('images/footer.png',
            array(
                'width'=>600,
                'height'=>72,
                'marginLeft' => -75,
                'positioning'=>'absolute',
                'posHorizontal' => 'absolute',
                'posVertical' => 'absolute',
            ));

And the second question, is it possible to put text on top of the image in the footer using phpword?


Solution

  • I solved my question. I used for footer:

    $footer->addImage('images/footer.png',
                array(
                    'width'=>600,
                    'height'=>72,
                    'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE,
                    'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE,
                    'posVertical' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE,
                    'marginLeft' => -75,
                    'marginTop'=>-50,
                    'wrappingStyle'=> 'behind'
                ));