Forum


Replies: 1   Views: 102
Extra line breaks

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.