Forum


Replies: 1   Views: 334
How do i fill a shape with a picture
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 cjohnsonuk  · 22-11-2018 - 11:50

The end result required is a round image from a stock square passport photo.  We're assuming the passport photo image has the face centred and they are all portrait in layout.

In word I can insert a any shape and change its fill from colour to picture and then just select the picture file for the fill.  This works great.

In phpdocx I can insert the shape but I only seem to be able to set the fillcolor property:

https://www.phpdocx.com/xmlapi-documentation/word-content/add-shape-Word-document-with-PHP

Is there a way to achieve this? 

I tried looking to see if I could create a square mask with a circular cut out.  I can't see how to do this in word but I can do it in Powerpoint and then paste it into Word.  If this is positioned correctly I can then match the colour of the square to my background and use this as a mask in a template document but its hardly ideal as it forces the circular photo into just one space on the page and so is no good if I want to create a staff list with cvarying length paragraph at the side of each image so I won't know where the masks need to be placed.  I've not tested this in phpdocx yet to see if I can get the zlevel of the photo correct to be behind the mask shape but in front of the plain colour image behind (which needs to be there in case there is no image to display).

 

Any help appreciated