Sample 18 Watermark

03:04:27 Create new PhpWord object
03:04:27 Write to Word2007 format
03:04:27 Write to ODText format
03:04:27 Write to RTF format
03:04:27 Write to HTML format
03:04:27 Write to PDF format ... NOT DONE!
03:04:27 Write to EPub3 format
03:04:27 Done writing file(s)
03:04:27 Peak memory usage: 4 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($phpWordbasename(__FILE__'.php'), $writers);
if (!
CLI) {
    include_once 
'Sample_Footer.php';
}