Forum


Replies: 1   Views: 2513
Center image using replacevariablebywordfragment
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 Adam Steff  · 29-04-2018 - 07:13

Hello, I've recently purchased the Premium package and I'm working with templates.

I've been trying center an image using replaceVariableByWordFragment, is that possible?

Also I've havn't been able to get replacePlaceholderImage working.

These are the steps I've been following:

  1. Right Click on image and select 'Add Alt Text'
  2. Add the value $IMAGE$ to the Alt Text Title
  3. Then I run this code $docx->replacePlaceholderImage('IMAGE',$to_folder_path.'/'.$file_name, ['target'=>'document']);

Any help would be appreciated.

$docx->replacePlaceholderImage('IMAGE',$to_folder_path.'/'.$file_name, ['target' => 'document']);

Posted by admin  · 29-04-2018 - 08:12

Hello,

Yes, you can set image properties when using replaceVariableByWordFragment. You need to set float and imageAlign properties as center and use a not inline textWrap with addImage. Also please set target as block with replaceVariableByWordFragment to overwrite the default align of the paragraph.

About replacePlaceholderByImage, we have done some tests and everything is working correctly. Please run the example included in the package (examples/Templates/replacePlaceholderByImage) and check it. If you still are unable to use the method, please send to contact[at]phpdocx.com your template and we'll check if the placeholder has been added correctly.

Regards.