I need to use a php function to fill a .docx template with some info of my Database. I was using some phpclass with rich text, but is really hard to get something nice... So i was doing some research and found this LiveDocx that come with Zend FW. But, i'm not using Zend, so i went a lil deeper and found a way to use LD without Zend...
I downloaded the libs, put them in my folder and tried to do one of the examples of the tutorial. The code is this one:
if (isset($_POST['exportar'])){
#!/usr/bin/php
// Turn up error reporting
error_reporting (E_ALL ^ E_DEPRECATED);
// Turn off WSDL caching
ini_set ('soap.wsdl_cache_enabled', 0);
// Define credentials for LD
define ('USERNAME', 'xxxxxx ');
define ('PASSWORD', 'xxxxxx');
// SOAP WSDL endpoint
define ('ENDPOINT', 'https://api.livedocx.com/1.2/mailmerge.asmx?WSDL');
// Set include path
set_include_path (dirname(__FILE__) . '/functions/lib');
// Include NuSOAP libary
require_once 'nusoap.php';
// Instantiate SOAP object and log into LiveDocx
$nuSoap = new nusoap_client(ENDPOINT, true);
// Set charset encoding for outgoing messages
$nuSoap->soap_defencoding = 'UTF-8';
// Log into SOAP service
$nuSoap->call('LogIn',
array(
'username' => USERNAME,
'password' => PASSWORD
)
);
// Upload template
$data = file_get_contents('./license-agreement-template.docx');
$nuSoap->call('SetLocalTemplate',
array(
'template' => base64_encode($data),
'format' => 'docx'
)
);
// Assign data to template
$fieldValues = array (
'software' => 'PetroAlianza Worksite',
'licensee' => 'Gerardo Leal',
'company' => 'PetroAlianza',
'date' => date('F d, Y'),
'time' => date('H:i:s'),
'city' => 'Ciudad Ojeda',
'country' => 'Venezuela'
);
$result = $nuSoap->call('SetFieldValues',
array(
'fieldValues' => nuSoap_assocArrayToArrayOfArrayOfString($fieldValues)
)
);
// Build the document
$nuSoap->call('CreateDocument');
// Get document as PDF
$result = $nuSoap->call('RetrieveDocument',
array(
'format' => 'docx'
)
);
$data = $result['RetrieveDocumentResult'];
file_put_contents('./license-agreement-document.docx', base64_decode($data));
// Log out (closes connection to backend server)
$nuSoap->call('LogOut');
unset($nuSoap);
print('DONE.' . PHP_EOL);
}
But when i try to export it i got this line:
[B]Fatal error:[/B] Call to undefined function nuSoap_assocArrayToArrayOfArrayOfString() in C:\xampp\htdocs\workbench\doc gen\doc_gen.php on line 75
So, What is going on..?.. Need some help there...
PD: If there is a better way to get this done. please let me know... :)
PPD: This is the link of the tutorial LiveDocx and nuSoup


Sign In
Create Account

Guest_GerarD_91_*
Back to top









