Forum


Replies: 3   Views: 504
How do i get bookmarks and fields that is in a template
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  · 26-04-2023 - 13:56

Hello,

Please note the following option available when using DOCXPath methods:

parent    string  Main document body as default, allows to set any parent or a specific one. w:body (default), '/' (any parent) or any other specific parent (/w:tbl/, /w:tc/, /w:r/...).

As default, the query is done only to direct children of the main tag (w:body). If you want to get all bookmarks, this is with any parent, you need to set parent to '/'. For example:

$docx->getDocxPathQueryInfo([
  'type' => 'bookmark',
  'parent' => '/',
]);

Also note that in a DOCX, a bookmark is a single tag without other contents. To extract fields using getDocxPathQueryInfo you may need to do a custom DOCXPath query. If you send a sample DOCX to contact[@]phpdocx.com we can generate a sample script to illustrate it.

Regards.