Forum


Replies: 1   Views: 326
Extra line breaks
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 jeremie  · 29-04-2024 - 14:24

The following HTML code should add only one blank line between the words "Foo" and "Bar":

<p>Foo<br><br></p><p>Bar</p>

But when embedding the code like this,

$docx->embedHTML('<p>Foo<br><br></p><p>Bar</p>');

the output Word document displays two blank lines between "Foo" and "Bar".

What am I missing?

Posted by admin  · 29-04-2024 - 16:15

Hello,

The HTML you are transforming contains two br tags, so two line breaks are added in the document. Each br tag is transformed to a w:br tag (https://www.phpdocx.com/htmlapi-documentation/html-standard/insert-break-Word-document-with-HTML).

Please note that although some browsers may hide extra contents or elements based on their own specifications, phpdocx transforms all supported tags and styles to MS Word. In this case, both br tags are transformed. If you only want to add one line break, please add only one br tag.

Regards.