Forum


Replies: 1   Views: 2667
Repeating headers in pages
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 dev@ram  · 17-05-2017 - 19:02

How do I add a header for a page which goes on repeating till another header is inserted.

For e.g. if there is a header called Introduction

        $headerText = new WordFragment($docx, 'defaultHeader');
        $headerText->addText('Introduction',array('pStyle' => 'Heading1'));
        $docx->addHeader(array('default' => $headerText));

After the content of the first page it should change to Introduction Continued for the next page contents.

This continues for each page until a new header is inserted. For e.g if I insert Summary as the next header, after the page fills up with contents, in the next page it will appear as Summary continued.

I checked the code xml inside the docx document.xml where it works and it looks like this:

<w:p w:rsidR="00832899" w:rsidRDefault="00832899" w:rsidP="00832899"><w:pPr><w:sectPr w:rsidR="00832899" w:rsidSect="001B2E7D"><w:headerReference w:type="default" r:id="rId13"/><w:footerReference w:type="default" r:id="rId14"/><w:headerReference w:type="first" r:id="rId15"/><w:footerReference w:type="first" r:id="rId16"/><w:type w:val="continuous"/><w:pgSz w:w="595.30pt" w:h="841.90pt" w:code="9"/><w:pgMar w:top="72pt" w:right="90pt" w:bottom="72pt" w:left="90pt" w:header="33.85pt" w:footer="39.60pt" w:gutter="0pt"/><w:cols w:space="35.40pt"/><w:docGrid w:linePitch="360"/></w:sectPr></w:pPr><w:r><w:fldChar w:fldCharType="end"/></w:r><w:bookmarkStart w:id="15" w:name="ContentsPg"/><w:bookmarkEnd w:id="15"/></w:p><w:p w:rsidR="00B21CA2" w:rsidRDefault="00B21CA2" w:rsidP="00B21CA2"><w:pPr><w:pStyle w:val="Heading1"/></w:pPr><w:bookmarkStart w:id="16" w:name="_Toc482365536"/><w:bookmarkEnd w:id="0"/><w:bookmarkEnd w:id="1"/><w:r><w:t>Introduction</w:t></w:r><w:bookmarkEnd w:id="16"/></w:p><w:p w:rsidR="00B21CA2" w:rsidRDefault="00B21CA2" w:rsidP="00B21CA2"><w:pPr><w:pStyle w:val="Heading1Line"/></w:pPr></w:p>

I know its pretty complex but any idea how to make header text like this ?

The heading here is text 'Introduction' with a blue underline and after the first page texts, in the next page it changes to Introduction continued. I noticed if I add a header using $docx->addHeader() , it remains the same throughout