添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

variablesBlock

This must be an array with the names of the placeholder block variables as keys and the plain text or WordFragment that should replace them as values.

The subarray 'images' can be added to do image replacements.

options

The possible keys and values of this array are: removeBlockPlaceholder False as default. If true, remove block placeholders from the cloned content. string Possible values are: inline (default) or block. Used by WordFragment values. require_once 'classes/CreateDocx.php'; $docx = new CreateDocxFromTemplate('template.docx'); $docx->cloneBlock('FIRST'); $docx->createDocx('output');

The resulting Word document looks like:

require_once 'classes/CreateDocx.php'; $docx = new CreateDocxFromTemplate('template.docx'); $docx->cloneBlock('EXAMPLE'); // clone block, 1st occurrence $docx->cloneBlock('SUB_1'); // clone block, 2nd occurrence $docx->cloneBlock('SUB_1', 2); // clone block, 4th occurrence $docx->cloneBlock('SUB_1', 4); // clone block, 2nd occurrence $docx->cloneBlock('SUB_2', 2); // clone block, 1st occurrence $docx->cloneBlock('SUB_2'); // remove block placeholders $docx->clearBlocks(); $docx->createDocx('output');

The resulting Word document looks like:

require_once 'classes/CreateDocx.php'; $docx = new CreateDocxFromTemplate('template.docx'); $image = new WordFragment($docx, 'document'); $image->addImage(array('src' => 'image.png' , 'scaling' => 50)); $link = new WordFragment($docx, 'document'); $link->addLink('Link to website', array('url'=> 'https://www.phpdocx.com')); // each array sets a new clone of the block $variables = array( array( 'VAR_MEMBER' => 'John Doe', 'VAR_CONTENT' => $image, 'VAR_DATE' => '11/08/2021', array( 'VAR_MEMBER' => 'Jane Doe', 'VAR_CONTENT' => $link, 'VAR_DATE' => '21/08/2021', // clone block setting the variables to be replaced $docx->cloneBlock('FIRST', 1, $variables, array('removeBlockPlaceholder' => true)); // delete remaining block $docx->deleteBlock('FIRST'); $docx->createDocx('output');

The resulting Word document looks like:

php docx is a product developed by 2mdc.com , a company specialized in the development of web apps since 1999.

About us

2023 © php docx

All rights reserved.