Sample 18 Watermark

00:22:09 Create new PhpWord object
00:22:09 Write to Word2007 format
00:22:09 Write to ODText format
00:22:09 Write to RTF format
00:22:09 Write to HTML format
00:22:09 Write to PDF format
00:22:09 Done writing file(s)
00:22:09 Peak memory usage: 4 MB

 

Results: docx odt rtf html pdf


<?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('resources/_earth.jpg', array('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';
}