Hi
I want to put image png on my doc I try with or without table.
But I open the doc with 2 differents Word and the look it's not the same for the 2 documents
How I can fix it?
Thanks
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
What's the difference? Can you attach screenshots or paste small part of your code?
The size is not the same in the 2 documents
include("../rProjections/FoyerChart.php");// generate the image
$table = $section->addTable();
$table->addRow(200,null);
$table->addCell(1300)->addImage("FoyerChart".$ClientID.".png",
array('width'=>600, 'height'=>200, 'align'=>'left'));
2014-05-05 9:35 GMT+02:00 Ivan Lanin [email protected]:
What's the difference? Can you attach screenshots or paste small part of
your code?—
Reply to this email directly or view it on GitHubhttps://github.com/PHPOffice/PHPWord/issues/224#issuecomment-42164899
.
Cordialement,
Corinne Zaoui
I'm unable to reproduce the error. I got the same image size when using this code:
$section->addImage('resources/_mars.jpg', array('width' => 100));
$cell = $section->addTable()->addRow(200)->addCell(1300);
$cell->addImage('resources/_mars.jpg', array('width' => 100));
Can you paste the code that you use to create the image without table?
Is this one solved too?
No the size are always not the same ...bigger in mac version
Le 9 mai 2014 12:16, "Ivan Lanin" [email protected] a écrit :
Is this one solved too?
—
Reply to this email directly or view it on GitHubhttps://github.com/PHPOffice/PHPWord/issues/224#issuecomment-42632052
.
I can reproduce, Word Mac and Word Windows do not display the images with the same dimensions.
Ok. I change the issue title.
I have seen this problem as well
Just curious, does any one have any idea's on this issue? I don't know enough of the docx format to even make a guess.
I haven't been able to reproduce the error. Can you take two screenshots that show the difference?
Here is the same word doc on both windows and mac office generated using the latest release.


I have the same problem.
I also have the same problem. This also holds for textboxes.
On windows every dimension of the Textbox (including margin values) is exactly 75% of the Mac Version.
Small Update from my side: It seems to be the conversion from px to pt.
I just created a document with Word 2007 just to see the difference in the textbox definition, as such a document produced the same result on a PC and on a Mac.
There I realized that the textbox dimensions are defined in pt.
After changing only the width and the margin top of the document created with PHPWord to pt, these dimensions where the same on a PC and on a Mac.
The solutions seems to be just converting and writing the values in pt.
Best regards
Florian
I have the same problem with images. Anything I can do to help / test / try?
The Mac version (2011) takes pixels; but uses as points, with the result that the image is 96px/72pt scaled.
The Windows version (2013) takes pixels; and when saving the .docx in Word, it changes it to points and does the correct conversion.
I made one small change in \src\PhpWord\Style\Image.php: row 63
Changed $this->setUnit('px'); to $this->setUnit('pt');
That fixed it.
im experiencing the same thing. ive checked the xml of the same document generated on a windows machine using word 2007, and a mac using 2011, but i see no difference in the xml. i believe this is referenced already, but mac 2011 calls pixels, "points". the images are enlarged by 133% which is what you get when you divide the pixel by point, 96/72.
because width and height can only be set by pixels, the mac version craps the bed.
edit: for the time being, i just run a regex to check $_SERVER['HTTP_USER_AGENT'] and set using points if mac is detected
Most helpful comment
I have the same problem with images. Anything I can do to help / test / try?
The Mac version (2011) takes pixels; but uses as points, with the result that the image is 96px/72pt scaled.
The Windows version (2013) takes pixels; and when saving the .docx in Word, it changes it to points and does the correct conversion.
I made one small change in \src\PhpWord\Style\Image.php: row 63
Changed $this->setUnit('px'); to $this->setUnit('pt');
That fixed it.