Replies: 3   Views: 487
Get header/footer content as plain text
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 bilalhh86  · 26-08-2022 - 06:18


iam using phpdocx-premium-12.5. i need to extract data as plain text from the header/footer.

iam able to get document data as text from document using



but i need to do the same get plain text with the header footer not only the document. i want to get all data of the document as plained text without tags.

Posted by admin  · 26-08-2022 - 06:58


You can use Indexer and getWordContents to extract contents and information from a DOCX


Posted by bilalhh86  · 26-08-2022 - 12:08


i use it like this to get text like the one i get it from the body

$docx = new \Phpdocx\Create\CreateDocxFromTemplate($documentPath);
$headerText = implode(' ', $docx->getWordContents(['target' => 'header']));

i get the data, is that correct?

Posted by admin  · 26-08-2022 - 12:20


Your username doesn't have any license tied, please send to contact[at] the username or email of the user that purchased the license you are using.

About your question, each method is focused on specific tasks and may not return the same exact outputs:

  • DOCX2TXT doesn't extract headers and footers contents. If you are interested on a custom development for this specific task, do not hesitate to contact us at contact[at]
  • getWordContents is focused on extracting specific contents using DOCXPath queries.
  • Indexer extracts information and also text contents.

We recommend you check the samples included in the package, that details how to use each method and you can use the method that best suits your needs.