Generate PDF and other document types using the Livedocx webservice in PHP.
You may know a Livedocx package already exists, so why did I bother reinvent the wheel?
The existing Livedocx package is tightly bound to Zend Framework components and requires a lot of dependencies. Requiring nearly half a framework to only use a single library felt like pure overkill to me.
I developped this Livedocx client with two point in mind:
Hope you will find it useful.
This package is unit tested with Atoum
This package requires:
*(Livedocx is unaffected by Heartbleed security leak)
To install this package using Composer, simply add this to you composer.json
file
"require" : {
"awakenweb/livedocx" : "1.0.1"
}
Available framework integration packages:
This package provides support for the following API:
As there is really few documentation about the shared documents feature, I did not add support for now. I may add it when I find some doc about how to use it.
First, a Livedocx account is required. It may be any account type: free, premium, or fully licenced.
The full documentation is in progress and should arrive shortly. For now, here is a simple example of usage. For more informations, take a look at the code.
<?php
use Awakenweb\Livedocx\Soap\Client;
use Awakenweb\Livedocx\Livedocx;
use Awakenweb\Livedocx\Container;
// for free accounts:
$wsdl = 'https://api.livedocx.com/2.1/mailmerge.asmx?wsdl';
// for premium:
$wsdl = "https://premium01.livedocx.com/REPLACE_THIS_BY_YOUR_USERNAME/mailmerge.asmx?WSDL"
// for fully licensed: only you may know
$soap = new Client(new \SoapClient($wsdl));
$soap->connect(USERNAME, PASSWORD);
$Livedocx = new Livedocx($soap, new Container());
$livedocx->assign(array(
'somefieldname' => 'some value',
'someOtherField' => 'another value'
)
);
$block = $livedocx->createBlock();
$block->setName('myblock');
$block->bind([
['firstfield' => 'some text', 'secondblockfield' => 'another text'],
['firstfield' => 'some other text', 'secondblockfield' => 'yet another text']
]);
$livedocx->assign($block);
$remoteTemplate = $livedocx->createRemoteTemplate();
$remoteTemplate->setName('myTemplate.docx')
->setAsActive();
$document = $livedocx->prepare();
$document->setPassword('$3CR3T');
$document->create();
file_put_contents('myPdfFile.pdf', $document->retrieve('pdf'));