Forum


Replies: 7   Views: 3599
Addheader with image not working in 2.5
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 lloyd_roles  · 27-04-2012 - 06:12

Below code to add an image to Header worked in phpdocx 2.4 Pro release.

$docx = new CreateDocx();

$paramsHeader = array(
'name' => '../../header.png',
'textWrap' => 5,
'font' => 'Times New Roman'
);

$docx->addHeader('', $paramsHeader);

The same doesn't work after upgrading to 2.5 release.

Got the below error, when file is opened.

The file report.docx cannot be opened because there are problems with the contents.

Details:
No error detail available.
Location: Part: /word/header.xml, Line: 1, Column: 1509

I see the below changes in 2.5, in /phpdocx/classes/CreateDocx.inc

//TODO: This is a temporary solution not to break the old addHeader method
if (!empty($this->_wordHeaderC) && $this->headerAdded) {
self::$log->debug('There is a new header, add it.');
$headerId = $this->generateTemplateWordHeader();
self::$log->info('Add word/header.xml content to DOCX file.');
$headerHandler = fopen($this->_baseTemplateFilesPath.'/word/header.xml', "w+");

addHeader might have been broken.

Please suggest a solution for this.
I really appreciate if I can know whether there is a solution or not.

Thanks.