Forum


Replies: 1   Views: 2449
Embedhtml - space in beginning and end
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 admin  · 23-05-2018 - 06:45

Hello,

You can use pre tags to keep extra spaces, but please note that you may need to set new styles to avoid default ones:

$docx->embedHTML('<p style="font-size: 16px; font-family: Calibri;">Sentence begins</p>');
$docx->embedHTML('<pre style="font-size: 16px; font-family: Calibri;"> and a previous   sentence continues </pre>');

Other approach would be using a WordFragment and adding spaces with addText:

$html = new WordFragment($docx);
$html->embedHTML('<p>and a previous sentence continues</p>');

$text = array();
$text[] = array('text' => ' ');
$text[] = $html;
$text[] = array('text' => ' ');

$docx->addText($text);

Regards.