Forum


Replies: 1   Views: 3248
Adding image issue
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 kalreg  · 15-08-2012 - 10:57

Hello,

I started to use PHPDocx library. I am still not sure if it is the best way to make docx files from PHP. For now I am stuck with such a problem:

I have an image and a long text. I'd like to have this image to be flooded (not sure if i use correct word to describe - sorry for that) by text. It should look like this:

text text text text text text ---------------------------
text text text text text text | |
text text text text text text | I M A G E |
text text text text text text | |
text text text text text text |________________|
text text text text text text text text text text text text
text text text text text text text text text text text text

My code looks like this:

$paramsImg = array(
'name' => '/images/image.jpg',
'scaling' => 1,
'spacingLeft' => 100,
'spacingTop' => 100,
'spacingRight' => 100,
'spacingBottom' => 100,
'textWrap' => 3,
'border' => 3,
'jc' => 'right'
);

$docx->addImage($paramsImg);

$paramsText = array(
'jc' => 'both',
'font' => 'Calibri'
);

$str = 'text text text text text';

$docx->addText($str, $paramsText);

Although I use multiple 'wordwrap' parameters and so on it always looks like this:

----------------------------
| |
| |
| I M A G E |
| |
|________________|
text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text

It also doesnt matter what is displayed first - text or image. Do you have any experience in image processing with phpdocx?
EDIT: one more thing - all formatting to image doesnt work - there is no border although it should be, spacing also doesnt work.. Dont know why.