PHP code example of dhutapratama / mydocx

1. Go to this page and download the library: Download dhutapratama/mydocx 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/ */

    

dhutapratama / mydocx example snippets


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