PHPOffice / PHPWord

A pure PHP library for reading and writing word processing documents
https://phpoffice.github.io/PHPWord/
Other
7.21k stars 2.68k forks source link

Supports loading of word files with images added on OneDrive #2245

Open pinekta opened 2 years ago

pinekta commented 2 years ago

Describe the Bug

Add images by editing Word in OneDrive and download Word files locally When loaded with PhpOffice\PhpWord\IOFactory::load Fixed a bug that caused PhpOffice\PhpWord\Exception\InvalidImageException.

If you unzip a normal Word file with zip /docProps /word /_rels Image files are in the directory It is saved as /word/media/xxx.png.

However, if it is a file with images added with OneDrive /docProps /media /word /_rels It is stored in the media directory of the directory called In getRels of PhpOffice\PhpWord\Reader\Word2007 Since it is assumed that the image exists in the/word/mediadirectory, The image in the/media` directory could not be read and an error occurred.

Steps to Reproduce

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

$phpWord = PhpOffice\PhpWord\IOFactory::load('/path/to/word_added_image_with_onedrive.docx');

Expected Behavior

Being able to load word files

Current Behavior

PhpOffice\PhpWord\Exception\InvalidImageException occurs

Context

If it is a word file with an image added on OneDrive Reproduce any PHP version or PHP Word version.

Progi1984 commented 3 weeks ago

@pinekta Hi, Could you send me a file with error, for analyzing it, please ?