Image size changes when excel exports to pdf

Topics: Developer Forum
Feb 22, 2012 at 2:14 AM

Hello,

I am creating a excel2007 file using PHPExcel 1.7.6 and it has a png image in the first row. I sized the the height of the image such that the width of the image spans exactly the columns I'm using (through trial-and-error). It looks great in excel, except that these are quote spreadsheets that will be exported to pdf using excel's built-in ability. When I do that, the image in the resulting pdf is smaller. Here is the relevant code:

$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Quote_Header');
$objDrawing->setDescription('Quote_Header');
$objDrawing->setPath('/var/www/img/grey_header.png');
$objDrawing->setHeight(151);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());

If it would help, I'll see if I can get some screenshots up. The upper-left corner of the image is correct in both formats, but the lower right is significantly different (as if the image was scaled down).

I suspect it has to do with specifying pixels per inch or something similar. It doesn't happen with a native Excel 2007 doc.

Thanks in advance for any insight.