PHP code example of madnh / phpword

1. Go to this page and download the library: Download madnh/phpword library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

madnh / phpword example snippets


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

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

$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);