Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php mail merge docx document

<?php

include_once('tbszip.php');

$zip = new clsTbsZip();

// Open the first document
$zip->Open('doc1.docx');
$content1 = $zip->FileRead('word/document.xml');
$zip->Close();

// Extract the content of the first document
$p = strpos($content1, '<w:body');
if ($p===false) exit("Tag <w:body> not found in document 1.");
$p = strpos($content1, '>', $p);
$content1 = substr($content1, $p+1);
$p = strpos($content1, '</w:body>');
if ($p===false) exit("Tag </w:body> not found in document 1.");
$content1 = substr($content1, 0, $p);

// Insert into the second document
$zip->Open('doc2.docx');
$content2 = $zip->FileRead('word/document.xml');
$p = strpos($content2, '</w:body>');
if ($p===false) exit("Tag </w:body> not found in document 2.");
$content2 = substr_replace($content2, $content1, $p, 0);
$zip->FileReplace('word/document.xml', $content2, TBSZIP_STRING);

// Save the merge into a third file
$zip->Flush(TBSZIP_FILE, 'merge.docx');
Comment

PREVIOUS NEXT
Code Example
Php :: auto complete order 
Php :: preared request pdo 
Php :: palindrom number in php 
Php :: php current url 
Php :: symfony functional test clear session and cookies 
Php :: public_path lumen not defined 
Php :: php gd coordinate 
Php :: hide category menu from custom post type 
Php :: woocommerce coupon notifie a spefic email 
Php :: $age = 20; print ($age = 18) ? "Adult" : "Not Adult"; 
Php :: best wordpress functions to include 
Php :: where post_type like 
Php :: wp functions ajax get 
Php :: laravel postgres deadlock 
Php :: check not empty in laravel blade 
Php :: mysqli_query() expects parameter 1 to be mysqli 
Php :: spatie/laravel-health 
Php :: YYYYMMDDTHHMMSSZ php 
Php :: wordpress custom post type url not working 
Php :: codeigniter AES _ENCRYPT or AES_DECRYPT in where 
Php :: t_lnumber php 
Php :: ttl jwt 
Php :: Drupal 9 Get taxonomy term objects by vocabulary machine name vid 
Php :: how to get name through id from mysql using php 
Php :: union type php does not work 
Php :: phpmyadmin account locked 
Php :: Call to undefined function can() laravel spatie 
Php :: subdomain ajax request fail in php 
Php :: Laravel model - CRUD only with records where one column = certain value 
Php :: add user role to wp admin page css 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =