superipey / phpword
Based on PHPOffice/PHPWord, some code modification for Any Image in Document to be recognized in TemplateProcessor
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
This package is not auto-updated.
Last update: 2025-03-27 19:21:13 UTC
README
This is only Modified PHPWord library based on PHPOffice/PHPWord library. I just put some modification in Word TemplateProcessor to recognize Images as a Template in the Document.
Thank you
Installation
This library is installed via Composer. To add a dependency to PHPWord in your project, either
Run the following to use the latest master version
composer require superipey/phpword:dev-master
You can of course also manually edit your composer.json file
{ "require": { "superipey/phpword": "dev-master" } }
Getting Started
First Step
To try this library modification, first create the template with the image placed anywhere in your document, right click on the image, then select Format AutoShape/Pictures
Second Step
Type your fieldname in the Alternative text
Third Step
Use setImageValueAlt to set the image
$template->setImageValueAlt(field, path-to-file);
Example:
$template->setImageValueAlt("foto", "./uploads/foto/ferry.png");
License
PHPWord is an open source project licensed under the terms of LGPL version 3. PHPWord is aimed to be a high quality software product by incorporating continuous integration and unit testing. You can learn more about PHPWord by reading the Developers' Documentation and the API Documentation.