Replies: 2   Views: 241
Add image to each page with custom position on each page of docx file
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 admin  · 16-03-2022 - 11:55


Internally, DOCX documents don't work with pages but with sections. The contents of a DOCX are displayed dynamically (all contents of a PDF are 'painted' in fixed positions, but DOCX documents don't work in the same way), for this reason, the exact output may vary depending on the program used to open the DOCX.
There's no method to add an image or any other content on specific pages because a DOCX doesn't contain page tags. A DOCX contains sections, paragraphs, tables, images, charts... but not pages. By default the addImage method adds the image at the end of the DOCX; using a WordFragment with the insertWordFragment method included in DOCXPath (only available in Advanced and Premium licenses, the trial package doesn't include this feature), you can insert new contents to specific positions of a DOCX. For example, you can insert a new image after the first content of the document, in the second section, before specific paragraphs, after each break..., so you'd need to know in what pages appear specific contents to be able to add new images in that positions.
Please check the documentation available on about DOCXPath.