Forum


Replies: 1   Views: 2344
How do i use replacevariablebytext in header with firstmatch option
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  · 08-11-2017 - 07:47

Hello,

The replaceVariableByText method allows to use the firstMatch option with all targets. But the main document is a single XML, and the number of headers may vary. If you set firstMatch as true and the target to header (or footer), the first placeholder of each header (or footer) will be replaced.

The best approach to accomplish your task is using unique placeholders for each header (first, even, odd or per section).

phpdocx 9.5 added support for headers and footers in DOCXPath (https://www.phpdocx.com/documentation/introduction/docxpath), so replacements and other workflows can be done based on the header/footer position and other queries not supported by replaceVariableByText.

Regards.