This project is read-only.

Replace a variable or create a footer text doesn't work for me.

Jan 27, 2011 at 3:42 AM

Hello there,

I've just started using PHPWord. I have a template file that contains variables to be replaced. But I also want to replace a part of the current footer, but I think setValue() doesn't work for footers right?

So I tried to create the footer using PHPWord. Here is the code I used which still doesn't work. (note that I am using a template file, not creating a new file)


	$anlasma_temp= 'form_template.docx';

	$PHPWord = new PHPWord();
	$document = $PHPWord->loadTemplate($anlasma_temp);

	$section = $PHPWord->createSection();
	$footer = $section->createFooter();
	$footer->addPreserveText('hi this is a text message', array('align'=>'center'));
	$olustur = $document->save('new.docx');

I was hoping to see my message on the footer :( Any ideas?

Feb 28, 2011 at 3:20 PM

use addText  instead of addPreserveText