madnh/phpword

PHPWord - A pure PHP library for reading and writing word processing documents (OOXML, ODF, RTF, HTML, PDF)

0.13.3 2017-03-21 05:42 UTC

README

Set image:

$templateProcessor->setImg('imageHolder', __DIR__ . DIRECTORY_SEPARATOR . 'resources/image.png');
//or
$templateProcessor->setImg('imageHolder', array('src' => __DIR__ . DIRECTORY_SEPARATOR . 'resources/image.png', 'swh' => '250'));

Set text:

$templateProcessor->setValue('serverName', realpath(__DIR__));
$templateProcessor->setText('special_charts', 'http://www.foo.com/index.php?a=1&b=2');

Set multiple lines of text

$multi_line_text = implode("\n", ['Text', 'value', 'in', 'multiple', 'of', 'lines']);
$templateProcessor->setText('multi_line_text_1', $multi_line_text);
$templateProcessor->setText('multi_line_text_2', $multi_line_text, true);

View samples/Sample_07_TemplateCloneRow.php as example.