Forum


Replies: 5   Views: 3613
Add header starting from page 2 onwards
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 anjanesh  · 10-03-2016 - 06:47

Is it possible to add header starting from page 2 ? Im using a template for page 1 which contains a background image.

$docx = new CreateDocxFromTemplate("template.docx");

$variables = [
    'SIGN' => "Testing Sign"
    ];

# Page 1 - import from template
$docx->replaceVariableByText($variables);

# Page 2
$docx->addBreak(array('type' => 'page'));

$textOptions = [
'b' => 'on',
'color' => '567899',
'backgroundColor' => 'feac0a',
'textAlign' => 'center'
];

$header = new WordFragment($docx, 'defaultHeader');
$header->addText("Header", $textOptions);

$docx->addHeader(array('default' => $header)); # I want this starting from page 2.

$text = 'Testing 123';
$docx->addText($text);