PHPOffice / PHPWord

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

Image not handled when converting a word document to pdf #1956

Open Mouke opened 4 years ago

Mouke commented 4 years ago

Describe the Bug

I am trying to convert a word file to PDF in order to process it afterwards (it has to be processed as a PDF), but if I include an image to my word, the lib wil crash.

Steps to Reproduce


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

        $reader = IOFactory::createReader();
        //$document is a Symfony\Component\HttpFoundation\File\UploadedFile object.
        $word = $reader->load($document->getPathname());
        $word->save($document->getPathname(), 'PDF');

### Expected Behavior

Should convert my word file into a pdf file of the same name, erasing the word file in the process.

### Current Behavior

When I execute this code snippet, i get the error `Warning: fopen(): Filename cannot be empty`, coming from PhpOffice\PhpWord\Element\Image line 377.

### Context

- PHP Version: 7.4
- PHPWord Version: 0.17.0

You'll find the docx file i use attached.

[test.docx](https://github.com/PHPOffice/PHPWord/files/5437779/test.docx)
romandots commented 3 years ago

Having the same issue when trying to convert .doc file to .pdf.

RayhanYulanda commented 2 years ago

Having the same issue when trying to convert .doc file to .pdf. +1