Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images produced by addImage look different in Word for Windows and Word for Mac #224

Closed
cocorem opened this issue May 5, 2014 · 16 comments

Comments

@cocorem
Copy link

cocorem commented May 5, 2014

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.

@ivanlanin
Copy link
Contributor

What's the difference? Can you attach screenshots or paste small part of your code?

@ivanlanin ivanlanin added this to the 0.11.0 milestone May 5, 2014
@cocorem
Copy link
Author

cocorem commented May 5, 2014

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//issues/224#issuecomment-42164899
.

Cordialement,

Corinne Zaoui

@ivanlanin
Copy link
Contributor

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?

@ivanlanin
Copy link
Contributor

Is this one solved too?

@cocorem
Copy link
Author

cocorem commented May 9, 2014

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//issues/224#issuecomment-42632052
.

@gabrielbull
Copy link
Member

I can reproduce, Word Mac and Word Windows do not display the images with the same dimensions.

@ivanlanin ivanlanin added Bug and removed Responded labels May 10, 2014
@ivanlanin ivanlanin changed the title addImage Images produced by addImage look different in Word for Windows and Word for Mac May 10, 2014
@ivanlanin
Copy link
Contributor

Ok. I change the issue title.

@ivanlanin ivanlanin removed their assignment May 10, 2014
@hskrtich
Copy link
Contributor

I have seen this problem as well

@ivanlanin ivanlanin modified the milestones: 0.12.0, 0.11.0 Jun 1, 2014
@hskrtich
Copy link
Contributor

hskrtich commented Jun 9, 2014

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.

@ivanlanin
Copy link
Contributor

I haven't been able to reproduce the error. Can you take two screenshots that show the difference?

@hskrtich
Copy link
Contributor

hskrtich commented Jul 3, 2014

Here is the same word doc on both windows and mac office generated using the latest release.

phpword_mac
phpword_win

@TimNuman
Copy link

TimNuman commented Nov 4, 2014

I have the same problem.

@fhaubner
Copy link

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.

@fhaubner
Copy link

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

@ghost ghost modified the milestones: 0.13.0, 0.12.0 Jan 3, 2015
@klompenrunner
Copy link

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.

@mattdelashaw
Copy link

mattdelashaw commented Nov 3, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

10 participants