cristiangomeze/template

Convert word templates to pdf

v0.0.12 2022-02-20 17:18 UTC

This package is auto-updated.

Last update: 2024-11-10 06:54:12 UTC


README

Latest Version on Packagist Total Downloads

This is a wrapper to use the phpword template, which allows you to have the final document rendered in the browser. Take a look at contributing.md to see a to do list.

Installation

Via Composer

$ composer require cristiangomeze/template

Usage

use Cristiangomeze\Template\Template;

$values = [
          'firstname' => 'John',
          'lastname' => 'Doe'
];

$valuesImages = [
    'company_logo' => [
        'path' => '/home/user/wallpaper/wallpaper.png',
        'width' => 200, 
        'height' => 200, 
        'ratio' => false
    ]
];

return Template::make('/home/user/any_word_document.docx')
        ->addValues($values)
        ->addImages($valuesImages)
        ->preview();
use Cristiangomeze\Template\Transforms\Transform;

$values = [
    [
        'key' => 'fecha',
        'value' => '2019-08-08',
        'transforms' => ['DateWords'] // DateWords, NumberWords, NumericFormat:2, DateFormat:LLLL
    ]
];

Transform::make($values)->toArray();

// 'fecha' => 'Ocho (8) Días del mes de Agosto del año Dos Mil Diecinueve (2019)'

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

license. Please see the license file for more information.