Sample 18 Watermark

20:08:30 Create new PhpWord object
20:08:30 Write to Word2007 format
20:08:30 Write to ODText format
20:08:30 Write to RTF format
20:08:30 Write to HTML format
20:08:30 Write to PDF format ... NOT DONE!
20:08:30 Write to EPub3 format
20:08:30 Done writing file(s)
20:08:30 Peak memory usage: 2 MB

 

Results: docx odt rtf html epub


<?php


include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new PhpOffice\PhpWord\PhpWord();

// Begin code
$section = $phpWord->addSection();
$header = $section->addHeader();
$header->addWatermark(__DIR__ . '/resources/_earth.jpg', ['marginTop' => 200, 'marginLeft' => 55]);
$section->addText('The header reference to the current section includes a watermark image.');

// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!
CLI) {
    include_once 
'Sample_Footer.php';
}