irebega/docx-replacer

PHP extension that allow you replace text to text or text to image in DOCX file

v1.1.0 2019-09-17 17:53 UTC

This package is auto-updated.

Last update: 2024-12-18 17:48:36 UTC


README

Latest Version on Packagist Software License Total Downloads

Extention is no longer supported.

Docx format has so much unconsistency in their xml files and I just can't predict every case. You still can use extension, but on your own risk.

Replace your variables to text or even to images in .docx files

Install

Require this package with composer using the following command:

composer require irebega/docx-replacer

Text to text replace

This code will replace $search to $replace in $pathToDocx file

$docx = new \IRebega\DocxReplacer\Docx($pathToDocx);

$docx->replaceText($search, $replace);

If you want search to be case insensitive use replaceTextInsensitive like:

$docx = new \IRebega\DocxReplacer\Docx($pathToDocx);

$docx->replaceTextInsensitive($search, $replace);

Text to image replace

This code will replace text $search to image that are located in $path in $pathToDocx file

$docx = new \IRebega\DocxReplacer\Docx($pathToDocx);

$docx->replaceTextToImage($search, $path);

License

PHP .docx replacer is open-sourced software licensed under the MIT license