PHP code example of waltdietzney / odt-template-engine
1. Go to this page and download the library: Download waltdietzney/odt-template-engine 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/ */
waltdietzney / odt-template-engine example snippets
$inspection = $template->inspect();
$template->bookmark('FullName')->replaceText('Jane Smith');
$experience = $template->section('ExperienceEntry');
declare(strict_types=1);
te;
$template = new OdtTemplate(__DIR__ . '/templates/example.odt');
$template->assign([
'customer_name' => 'Jane Smith',
]);
$template->assignRepeating('items', [
['name' => 'Tea', 'price' => '3.50'],
['name' => 'Coffee', 'price' => '4.20'],
]);
$template->render();
$template->save(__DIR__ . '/output/example-result.odt');
use OdtTemplateEngine\Elements\Paragraph;
use OdtTemplateEngine\Elements\RichText;
$paragraph = new Paragraph();
$paragraph
->addText('Hello ', ['bold' => true])
->addText('world!', ['italic' => true]);
$richText = new RichText();
$richText->addParagraph($paragraph);
$template->setElement('intro', $richText);
$template->styles()->defineParagraph('ReportHeading', [
'margin-top' => '0.3cm',
'margin-bottom' => '0.1cm',
]);
$heading = new Paragraph('ReportHeading');
$experiences = $template
->section('ExperienceEntry')
->instantiateMany([
['note' => 'Current role', 'position' => 'Senior Project Manager'],
['note' => 'Previous role', 'position' => 'Project Coordinator'],
]);
$template = new OdtTemplate(__DIR__ . '/templates/example.odt');
$template->setUserField('customer', 'Jane Smith');
$template->save(__DIR__ . '/output/example-result.odt');
bash
php -S localhost:8085 -t demo/sample-explorer