PHPWord icon indicating copy to clipboard operation
PHPWord copied to clipboard

Template replace not working in footer

Open rajasaur opened this issue 4 years ago • 2 comments

Describe the Bug

Some of the word documents(docx) that we create have only word/footer.xml or word/header.xml for the footer/header information.

With this logic, it looks like they are being skipped from replacing as the TemplateReplacement logic in https://github.com/PHPOffice/PHPWord/blob/develop/src/PhpWord/TemplateProcessor.php#L119 and https://github.com/PHPOffice/PHPWord/blob/develop/src/PhpWord/TemplateProcessor.php#L124 only seem to look for documents with word/footer<number>.xml and word/header<number>.xml

Shouldnt it also check for the simple word/header.xml and word/footer.xml ?

Steps to Reproduce

Attached word document when expanded will show the word/footer.xml and word/header.xml.. Trying to run a template replace on this avoids replacing any tags that are available in the footer (Because of the logic mentioned above).

This seems to happen only on Word docs created online, not the desktop version

Expected Behavior

The expected behaviour is for all template variables to get replaced

Current Behavior

Only variables in the main body get replaced and not the header/footer

Context

  • PHP Version: 5.6.39
  • PHPWord Version: 0.16.0 installed using composer.

Test file

Karnan's Custom Form-1.docx

rajasaur avatar Jan 09 '21 03:01 rajasaur

is there any update on this? i also having the same issue

FareedR avatar May 11 '23 01:05 FareedR

no update on this?!

robertnicjoo avatar Apr 15 '24 07:04 robertnicjoo