Images and ImagesRoot for HTML output

Topics: User Forum
Jul 21, 2011 at 5:16 PM

I am using PHPExcel to create a "printable" page of a schedule. I want an image in the header and when setting the path for a drawing, I know that you must use the absolute path to the file or you get an exception.

$objDrawing->setPath('/srv/www/htdocs/logo.png'); 

vs.

// gives File Not found exception, even though the logo.png file is actually in the root
$objDrawing->setPath('/logo.png'); 


So, when I export to HTML, I set the ImagesRoot:

// $server variable has uri to document root
$objWriter->setImagesRoot($server);

But the link comes out like this:
http://staging.cic.scic.com/srv/www/htdocs/logo.png

Any ideas?
Jul 21, 2011 at 5:33 PM

I've also found that setting the path to an absolute path causes problem in PDF output as well.

Setting it to '/srv/www/htdocs/logo.png' causes TCPDF to look for it on a relative path and I get this error:

<strong>TCPDF ERROR: </strong>[Image] Unable to get image: ./srv/www/htdocs/logo.png

Note the dot. This means that any image you want to include must be in a directory below the directory where your script is, is that what I'm reading here?

Jan 27, 2013 at 9:11 PM
Edited Jan 27, 2013 at 9:12 PM

Any update to this? It loads the image correctly in Excel but there is problems with PDF & HTML output. I am included the image like

 

$objDrawing->setPath("/home/www/domain.com/public_html/images/logo.gif");

 

 

PDF Files give error
TCPDF ERROR: [Image] Unable to get image: ./home/www/domain.com/public_html/images/logo.gif

 

HTML Output

<img style="left: 0px; top: 0px; width: 110px; height: 50px;" src="./home/www/domain.com/public_html/image/logo.gif" border="0" alt="" width="110" height="50" />