Forum


Replies: 2   Views: 1198
Problems with character & in bulkprocessing
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 17-03-2021 - 10:00

Hello,

Please send the DOCX template you are using to contact[at]phpdocx.com so we can check it.

Also please note that BulkProcessing (https://www.phpdocx.com/documentation/introduction/bulk-processing-documents-PHP) uses arrays in arrays to generate the documents, for example (included sample BulkProcessing/replaceText/sample_2.php):

$variables = 
array(
    // first DOCX
    array(
        'date' => date('Y/m/d'),
        'name' => 'John',
        'address' => 'Acme Street 1',
        'url' => 'https://www.phpdocx.com',
        'signature' => 'phpdocx',
        'footer' => 'phpdocx\nfooter',
    ),
    // second DOCX
    array(
        'date' => date('Y/m/d'),
        'name' => 'Mary',
        'address' => 'Acme Street 2',
        'url' => 'https://www.phpdocx.com',
        'signature' => 'phpdocx',
        'footer' => 'phpdocx\nfooter',
    ),
    // third DOCX
    array(
        'date' => date('Y/m/d'),
        'name' => 'Tom',
        'address' => 'Acme Street 3',
        'url' => 'https://www.phpdocx.com',
        'signature' => 'phpdocx',
        'footer' => 'phpdocx\nfooter',
    ),
);
$options = array(
        'parseLineBreaks' => true,
);

$bulk->replaceText($variables, $options);

The first subarray is only for the first DOCX to be generated, the second subarray for the second DOCX to be generated and so on. Maybe you setting the placeholders for multiple DOCX when you need to set them for a single DOCX?

BulkProcessing feature (https://www.phpdocx.com/documentation/introduction/bulk-processing-documents-PHP) allows generating multiple DOCX outputs based on the same template. But if you need to generate a single DOCX output from a template, the best solution is using template methods (https://www.phpdocx.com/documentation/practical/working-with-templates).

Regards.