News
List with image, list, chart and textbox with PHPdocx
- May 03, 2011
This information is outdated, please, refer to the current addList, addChart and addTextBox documentation for up to date info.
Now we may go a little bit further and learn how to work concurrently with several different types of content that we learnt to use in recent posts: this time we will create a List with an image,a simple list, a chart and a textbox with PHPdocx.
The required loks like this:
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();
// Here we start with the link
$paramsLink = array(
'title' => 'Link to Google',
'link' => 'http:// www.google.es'
);
$link = $docx->addElement('addLink', $paramsLink);
// Here start how to add an image
$paramsImage = array(
'name' => '../files/img/image.png'
);
$image = $docx->addElement('addImage', $paramsImage);
// Here starts the Chart; in our code, is a Pie chart in 3D
$legends = array(
'legend1' => array(10, 11, 12),
'legend2' => array(0, 1, 2),
'legend3' => array(40, 41, 42)
);
$paramsChart = array(
'data' => $legends,
'type' => 'pie3DChart',
'title' => 'Title'
);
$chart = $docx->addElement('addGraphic', $paramsChart);
// Here start the code for the text box
$paramsText = array(
'b' => 'single'
);
$paramsBox = array(
'jc' => 'square'
);
$paramsTextBox = array(
array(
'text' => 'Lorem ipsum dolor sit amet, consectetur adipisicing ' .
'elit, sed do eiusmod tempor incididunt ut labore et ' .
'dolore magna aliqua. Ut enim ad minim veniam, quis ' .
'nostrud exercitation ullamco laboris nisi ut aliquip ' .
'ex ea commodo consequat. Duis aute irure dolor in ' .
'reprehenderit in voluptate velit esse cillum dolore ' .
'eu fugiat nulla pariatur. Excepteur sint occaecat ' .
'cupidatat non proident, sunt in culpa qui officia ' .
'deserunt mollit anim id est laborum.',
'args' => $paramsText
),
$paramsBox
);
$textBox = $docx->addElement('addTextBox', $paramsTextBox);
// And here construct the document with all the code
$valuesList = array(
'Line 1',
$link,
$image,
$chart,
'Line 2',
'Line 3',
$textBox,
);
$paramsList = array(
'val' => 1
);
$docx->addList($valuesList, $paramsList);
// Time to create the docx document!
$docx->createDocx('example_list');