Forum


Replies: 5   Views: 3679
Using replacevariablebyhtml to generate a document with a centered image does not seem to work.
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 nicks  · 01-11-2015 - 17:05

I'm using ckeditor to allow my users to create content, including pictures that can be justified center. An example of the HTML generates is below:

<p style="text-align:center"><img alt="" height="500" src="ckeditor/plugins/imageuploader/../../../ckeditor/plugins/imageuploader/uploads/113995b1.png" width="900" /></p>

While it includes the image fine, it is always left justified. No filtering is in place that I know of, and just to prove a point, I created a one off test page:

<?php
require_once '../phpdocx_corporate-new/classes/CreateDocx.inc';
$docx = new CreateDocxFromTemplate('Report_Empty1.docx');
$docx->replaceVariableByHTML('PIC', 'inline', '<center><img alt="" height="500" src="ckeditor/plugins/imageuploader/../../../ckeditor/plugins/imageuploader/uploads/113995b1.png" width="900" /></center>
', array('isFile' => false, 'parseDivsAsPs' => true, 'downloadImages' => true));
$docx->createDocx('Output3');
?>

Am I missing something, or is a bug?

Posted by nicks  · 02-11-2015 - 14:25

Thanks, I'll give that a go!

Posted by nicks  · 12-11-2015 - 11:01

So the code changes works to center the image, however when there's text following the image, after generating the document using PHPDOCX, the text that follows the image is wrapped around it.

How do I solve this?

 

 

Posted by admin  · 12-11-2015 - 12:23

Hello,

You can use WordFragments or try using the textWrap parameter.

Regards.

Posted by nicks  · 12-11-2015 - 14:46

Understood. How would I go about this with replaceVariableByHTML? Any examples or documentation?

 

Thanks