This project is read-only.

Images in Windows Word 2010, Mac Word 2011 scale differently

Nov 1, 2011 at 10:26 PM

I'm having an issue here where docx files created by PHPWord appear identical on Mac Word 2011 and Windows Word 2010, except that the Mac images appear slightly (20%?) larger.

If the Windows machine opens the PHPWord docx file (Word 2007, presumably), saves it as a Word 2010 docx file, and then is opened by Mac Word 2011, the file appears normally.

Ideally it would be perfect to scale images by inches like everything else, instead of by pixels.

Any ideas what might be wrong, or what potential solutions I could use?  I'd rather not do a "If browser client is a mac, scale images 20% smaller".

Nov 1, 2011 at 10:47 PM

OK, fixed this... In Writer's Base.php, I've changed:

$objWriter->writeAttribute('style', 'width:'.$width.'px;height:'.$height.'px');


$objWriter->writeAttribute('style', 'width:'.$width.'in;height:'.$height.'in');

This should lead to a much more consistent experience across different versions of Word, but will break things horribly for existing code.  Windows Word 2010 appears to scale 96 pixels to an inch, and taking a wild guess I'd say Mac Word 2011 scales 72 pixels to an inch.

Would a more sensible approach be to print in inches, but to do a 96px = 1in conversion in Style/Image.php?