I am trying to change the alignment of the image added into the docx file, but the alignment is not working. I have tried as below:
$templateProcessor->setImageValue($tag->template_tag,
array(
'path' => $filePath,
'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE,
'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END,
)
);
Though the image is rendered in exported docx file, however the image alignment is always left. How can I change the alignment of image to either center or end?
CodePudding user response:
You are using positionning settings reserved when
...you got the following replacement (Replaced.docx
in the code)
If you center the image placeholder... ...the replace image is centered !
The second argument, named $replace
, of the method setImageValue
of the TemplateProcessor
class (added in the 0.16 version) can be an associative array but it only supports 3 values (quoted from the docBlock of the method) :
@param mixed $replace Path to image, or array("path" => xx, "width" => yy, "height" => zz)