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
Requires
- php: >=5.3.3
- ext-xml: *
- phpoffice/common: 0.2.*
- zendframework/zend-escaper: 2.4.*
- zendframework/zend-stdlib: 2.4.*
- zendframework/zend-validator: 2.4.*
Requires (Dev)
- dompdf/dompdf: 0.6.*
- mpdf/mpdf: 5.*
- phpdocumentor/phpdocumentor: 2.*
- phploc/phploc: 2.*
- phpmd/phpmd: 2.*
- phpunit/phpunit: 3.7.*
- squizlabs/php_codesniffer: 1.*
- tecnickcom/tcpdf: 6.*
Suggests
- ext-gd2: Allows adding images
- ext-xmlwriter: Allows writing OOXML and ODF
- ext-xsl: Allows applying XSL style sheet to headers, to main document part, and to footers of an OOXML template
- ext-zip: Allows writing OOXML and ODF
- dompdf/dompdf: Allows writing PDF
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.