Forum


Replies: 4   Views: 2906
Images in headers
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 fortech  · 26-07-2011 - 14:44

I'll trying to place an image in the header. I have:

$header = '';
$paramsImg = array(
'name' => $_SERVER['DOCUMENT_ROOT'].'/img/header.png',
'scaling' => 100,
'spacingTop' => 100,
'spacingBottom' => 0,
'spacingLeft' => 100,
'spacingRight' => 0,
'textWrap' => 1,
'js' => 'center',
'border' => 1,
'borderDiscontinuous' => 1
);


$docx->addHeader($header, $paramsImg);

I get the image importing fine, however the image has a width of 0" and height of (basically infinite). I've tried the sixeX, sixeY with other combinations, with no change in results. Am I missing a param to make it work? Thanks.

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

The code seems to be ok, so try with relative path to image.

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

nope, same result.

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

I think I found the root cause.

classes/CreateImage::
private function getDpiPng($filename)
{
$a = fopen($filename, 'r');
$string = fread($a, 1000);
$aux = strpos($string, 'pHYs'); // <-- $aux = 0, pHYs is not in the file
$data = bin2hex(substr($string, $aux + strlen('pHYs'), 16));
fclose($a);
$x = substr($data, 0, 8);
$y = substr($data, 8, 8);
return array(hexdec($x), hexdec($y));
}