PHP Library for merge, find some text and replace to text or image in docx document. Note that this library is never tested for OpenOffice format.
This library is downloaded from https://github.com/jupitern/docx since no update from Dec 2016. Issue are very welcome to report here.
- Find text and replace with text and image
- Merge docx files on one file
Note : Merge document here is include new file into existing file and show as one document or existing page is not modified
- PHP 5.4 +
MyDocx is installed via Composer. To add a dependency to MyDocx in your project, either
Run the following to use the latest stable version
composer require dhutapratama/mydocxYou can of course also manually edit your composer.json file
{
"require": {
"dhutapratama/mydocx": "v1.0.*"
}
}use Dhutapratama\MyDocx\Docx;
// Initialization
$myDocx = new Docx('/mydir/template.docx');$myDocx->setHeaderFooter(['text_to_find' => 'value to replace'])
->save();$myDocx->setText(['text_to_find' => 'value to replace'])
->save();$myDocx->setImage(['text_to_find' => '/your/image.png'])
->save();$myDocx->setMerge(['/your/file1.docx', '/your/file2.docx'])
->save();$myDocx->setText(['text_to_find' => 'value to replace'])
->setImage(['text_to_find' => '/your/image.png'])
->setMerge(['/your/file1.docx', '/your/file2.docx'])
->save();Please report any issue or you can also help others to resolving issues by fork and requesting merge to master branch.