Forum


Replies: 2   Views: 206
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 amit13  · 16-03-2022 - 11:39

i want to put images on each pages with my custom different different position. can you please suggest any link or example ? we have successfully read our existing doc and added image to that but it is adding image on last page only we want it to be added on specific pages with our custom different different positions. Thanks

Posted by admin  · 16-03-2022 - 11:55

Hello,

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 https://www.phpdocx.com/documentation/introduction/docxpath about DOCXPath.
 
Regards.

Posted by juanmark  · 19-04-2022 - 09:05

Deleted by admin · 19-04-2022 - 09:22