phpphpwordphpoffice

PhpOffice/PhpWord image wrapping doesn't work


I use PhpWord to generate a .docx file using TemplateProcessor. In the script, I include an image with a statement

$templateProcessor->setImageValue('aName', [
    'path' => '/path/to/file',
    'positioning' => Frame::POS_RELATIVE,
    'width' => '55mm',
    'height' => '60mm',
    'wrappingStyle' => Frame::WRAP_INFRONT,
]);

It is killing me already for 3 days, but the wrapping of the image does not work (I mean putting the image behind or in front of text). I googled solutions to no avail.

Edit. The image is inserted into the .docx template, but its text wrapping is inline, not in front of.

I tried a bunch of solutions I googled, including the most widespread one supplying 'positioning' => 'relative' to the options of the setImageValue(). But as mentioned, no avail.

Could anyone please help?


Solution

  • After more than a week of trying, I dropped it and used a workaround: I used a transparent text box, put a variable in it to be later replaced by the image, and put the text box in front of text. This solved my problem.