Forum


Replies: 1   Views: 527
How i am give the background to header please share code
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 keyhiresworld  · 12-09-2022 - 13:04

I have an issue in code when I create my word file there is a header and the footer come up by default so I try first to remove the header but it does not work ..  so we are got to the next step we make the default to our header make it customize but there come up another issue we face how to set the complete header background color thanks.

Posted by admin  · 12-09-2022 - 13:26

Hello,

You can apply paragraph background colors to text contents in headers, footers, body and other scopes of the document. MS Word doesn't include a content/tag/style to apply a background color to headers or footers that fill the whole header/footer; only to the whole document (as setBackgroundColor does).
To set background colors to headers and footers You need to add contents such as a shape or a table or an image:

https://www.datanumen.com/blogs/8-ways-to-set-different-background-colors-for-header-footer-and-main-document-in-word/

https://www.wyzant.com/resources/answers/688041/header-and-footer-backgrounds-in-word-2010

We recommend you generate a DOCX template with the needed content and use it with the CreateDocxFromTemplate class. Using DOCXCustomizer, available in Premium licenses, you can customize existing styles in DOCX documents dynamically; for example to customize the color applied to a shape.

Regards.