Forum


Replies: 7   Views: 3597
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.

Posted by seb  · 11-04-2013 - 12:13

Hi,

I also can't get images to appear in the header. I've tried relative image paths, full image paths, even a URL to the image, but nothing is displayed.

Can we please get an update on this?

Thanks,
Seb

Posted by admin  · 11-04-2013 - 12:13

Hello,

Please use the latest version of PHPDOCX that you can download in your MYPHPDOCX page.

Regards.

Posted by seb  · 11-04-2013 - 12:13

Sorry I didn't realise we were talking about version 2.5.

I maintain that this is still not working in the latest version 2.7 release.

Posted by admin  · 11-04-2013 - 12:13

Hello,

I have replied your issue in this topic:

http://www.phpdocx.com/help/forum?vasthtmlaction=viewtopic&t=2841.0

Regards.

Posted by kph  · 11-04-2013 - 12:13

I do not understand the answer from the Admin?

In the header i do not see the picture...the picture is well visable in the rest of the Word document


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

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

$paramsImg = array(
'name' => ''.$Header_Bestandslocatie_row2.'',
'scaling' => 20,
'spacingTop' => 0,
'spacingBottom' => 0,
'spacingLeft' => 0,
'spacingRight' => 0,
'textWrap' => 1,
'border' => 0,
'borderDiscontinuous' => 1
);

$docx->addImage($paramsImg);

Posted by kph  · 11-04-2013 - 12:13

Ive tryed the example but the example is only showing a white surface...