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

PHPWord generated documents have a border around images in LibreOffice Writer #2031

Closed
prescriptionlifeline opened this issue Mar 4, 2021 · 4 comments · Fixed by #2021
Closed

Comments

@prescriptionlifeline
Copy link

Describe the Bug

PHPWord generated documents have a border around images in LibreOffice Writer. This border is not present in Microsoft Word and I do not want it to be present

Steps to Reproduce

Please provide a code sample that reproduces the issue.

<?php
require __DIR__ . '/vendor/autoload.php';

use \PhpOffice\PhpWord\PhpWord;

$PHPWord = new PhpWord();
$section = $PHPWord->createSection();
$section->addImage('logo.png');

$PHPWord->save('test.docx', 'Word2007');

For the purposes of this demo I used https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png as the local logo.png.

Expected Behavior

This is how it looks in Microsoft Word:

image

Current Behavior

This is how it looks in LibreOffice Writer:

image

LibreOffice Writer is perfectly capable of showing images in Word documents without borders. Case in point: it does so with documents created with Microsoft Word 2019 and with documents it generates itself.

Context

Please fill in your environment information:

  • PHP Version: 7.4.9
  • PHPWord Version: 0.18.0
  • Microsoft Word: 2019
  • LibreOffice Writer: 7.0.1.3

Here are the files:

PHPWord 0.18.0 generated document
Microsoft Word 2019 generated document
LibreOffice Writer 7.0.1.3 generated document

@prescriptionlifeline
Copy link
Author

prescriptionlifeline commented Mar 4, 2021

Here's the word/document.xml that Microsoft Word 2019 produced:

https://pastebin.com/U6nRZ8WC

Here's the word/document.xml that PHPWord 0.18.0 produced:

https://pastebin.com/7dYUHrtj

Here's the word/document.xml that LibreOffice 7.0.1.3 produced:

https://pastebin.com/faWmmdZr

I note that only PHPWord uses v:shape or v:imagedata.

@madeingnecca
Copy link

I can confirm this issue.

@kamilmmach
Copy link
Contributor

I've created a PR #2021 that solves this issue

@madeingnecca
Copy link

Patched Phpword using the PR's patch and it worked great, thanks.

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

Successfully merging a pull request may close this issue.

3 participants