Forum


Replies: 1   Views: 2586
Png image malformed ?
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by k.barendrecht  · 04-01-2018 - 15:48

Jpeg, EMF, WMF, GIF images all are fine after being added to word, but PNG images are malformed in word (the streams I use are all perfectly fine, tested by decoding the streams on the web);

Original image 

Malformed in Word

I can mail the word file upon request.

Code below:

             /** @var FlowchartDefinition $content */

                FileStreamHelper::registerStream($content);

        $image = new WordFragment($docx, 'document');
        $image->addImage([
            'name' => $content->getFileId(),
            'src' => FileStreamHelper::generateStreamUri($content),
            'dpi' => 96,
            'width' => $content->getWidth(),
            'height' => $content->getHeight(),
            'target' => 'document',
                        'mime' => $content->getMimeType()
                ]);

        $docx->replaceVariableByWordFragment([$placeHolder => $image], ['type' => 'inline']);

                FileStreamHelper::unregisterStream($content);