Skip to content

Images not displayed when using RTF, DOCX or PDF writer? #431

@dwalker109

Description

@dwalker109

Hi, I am new to PHPWord and I am struggling with embedded images. The following code works fine if I output to HTML or ODText, but produces a seemingly blank document when using the Word2007, PDF or RTF writers:

$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$section->addImage(
    '/vagrant/tmp/test.jpg',
    array(
        'width' => 600,
        'height' => 402,
    )
);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('/vagrant/tmp/'.uniqid().'.docx');
echo 'DONE';

I have also run Sample_13_Images.php, which does the same thing - HTML and ODText output is fine, other formats are not.

The actual filesize is inflated by the size of the image (so it does appear to be embedded) but it does not appear.

I don't see any errors in the Apache log. I am using CentOS 6.4 and PHPWord 0.11.1. PHP-GD and PHP-XML are installed.

Hope I'm not being stupid!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions