Download the PHP package jhon/word_replacer_wrapper without Composer

On this page you can find all versions of the php package jhon/word_replacer_wrapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package word_replacer_wrapper

word replacer wrapper

replace words on .docx files and convert to pdf

install with

composer require jhon/word_replacer_wrapper

Dependencies

You need to install LibreOffice.

Usage

You must include vendor/autoload.php

require __DIR__ . '/vendor/autoload.php';

Class namespace

use Jsvptf\WordReplacerWrapper\WordReplacerWrapper;

Default configuration

//template to process
$template = 'templateDirectory/test.docx';

Define data to convert

//array of ITypeTableChild elements
$tableData = [
        [
            new Text('a'),
            new Text('b'),
        ],
        [
            new Text('d'),
            new Table($nestedTableData),
        ]
];

//default configuration, array of IType elements

$data = [
    'field1' => new Text('xxxxxxxxxxx'),
    'field2' => new Table($tableData),
    'field3' => new Image('./images/test.png', 80, 80),
    'field4' => new Pagination('Page {PAGE} of {NUMPAGES}.'),
    'styleText' => new Text('some with style', [
        'size' => 20,
        'bold' => true,
        'name' => 'Courier New'
    ])
];

//folder for create files
$temporalDirectory = 'testOne';

$WordReplacerWrapper = new WordReplacerWrapper(
    'templateDirectory/test.docx', //docx template
    $data, //data to replace
    'prueba1', //destination folder
    'libreoffice' //libreoffice binary
);

//execute replace and convert to pdf
$routes = $WordReplacerWrapper->replaceData();

//routes
["template"]=>
  string(17) "testOne/test.docx"
["document"]=>
  string(26) "testOne/document_test.docx"
["pdf"]=>
  string(25) "testOne/document_test.pdf"

Dinamic configuration

//if you want to know the required variables you can use  
$fields = $WordReplacerWrapper->getRequiredFields()

//$fields
array(7) {
  [0]=>
  string(6) "field1"
  [1]=>
  string(6) "field3"
  [5]=>
  string(6) "header"
  [6]=>
  string(6) "footer"
}

$WordReplacerWrapper->setData(['field1' => new Text('sebastian')]);
$WordReplacerWrapper->setTemporalDir('testTwo');
$routes = $WordReplacerWrapper->replaceData();

//routes
["template"]=>
  string(17) "testTwo/test.docx"
["document"]=>
  string(26) "testTwo/document_test.docx"
["pdf"]=>
  string(25) "testTwo/document_test.pdf"

Header and footer

you must add header and footer key to data, implementing a Jsvptf\WordReplacerWrapper\types\Table class and the template file MUST has content on header and footer space, you can see it on example/convertDocx.php

$data = [
    'header' => new Table($tableData),
    'footer' => new Table($tableData)
    ...
];

You can find the complete example on example directory


All versions of word_replacer_wrapper with dependencies

PHP Build Version
Package Version
Requires phpoffice/phpword Version ^0.17.0
ncjoes/office-converter Version ^1.0
ext-zip Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jhon/word_replacer_wrapper contains the following files

Loading the files please wait ...