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 style is invalid when set 'wrappingStyle'='behind' #1112

Closed
yule2001 opened this issue Jul 28, 2017 · 3 comments
Closed

Images style is invalid when set 'wrappingStyle'='behind' #1112

yule2001 opened this issue Jul 28, 2017 · 3 comments

Comments

@yule2001
Copy link

yule2001 commented Jul 28, 2017

I want to add a image in header,and make it behind text, so I set
$img_style = [
'positioning' => 'absolute',
'marginLeft' => 45,
'marginTop' => -44,
'width' => 100,
'height' => 94,
'wrappingStyle' => 'behind',
'posHorizontal' => 'absolute',
'posHorizontalRel' => 'page',
'posVertical' => 'absolute',
'posVerticalRel' => 'line',
];
but I find that the image always front the text.
At last, I modify the file "PhpOffice\PhpWord\Writer\Word2007\Style\Frame.php"
Line 44:
$zIndices = array(FrameStyle::WRAP_INFRONT => PHP_INT_MAX, FrameStyle::WRAP_BEHIND => -PHP_INT_MAX);
new code:
$maxIndex = PHP_INT_MAX > 251659264 ? 251659264 : PHP_INT_MAX;
$zIndices = array(FrameStyle::WRAP_INFRONT => $maxIndex, FrameStyle::WRAP_BEHIND => -$maxIndex);
The result was what I wanted. Wish it could help people with the same confusion.
By the way, constant values in "PhpOffice\PhpWord\Style\Image.php" misguide me.
the style "posHorizontal" and "posVertical" both can set 'absolute'.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@praveshpushp
Copy link

Thanks yule2001, I had the same issue and your hack worked for me.

@troosan
Copy link
Contributor

troosan commented Jan 12, 2018

@yule2001 @praveshpushp do you still have this issue with version 0.14?
This should have been fixed by #1178
Feel free to reopen this issue if not fixed.

@troosan troosan closed this as completed Jan 12, 2018
@yule2001
Copy link
Author

@troosan ,thanks for your reply.

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

No branches or pull requests

3 participants