Forum


Replies: 7   Views: 2766
Embedhtml 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 nohope100  · 06-07-2017 - 15:23

There seems to be an issue with <ul> and <ol> when there is valid html within the list tags when using embedHTML.

$docx->embedHTML('<ul><li><p>Some text.</p></li></ul>');

 for instance if you have <ul><li><p>Some text.</p></li></ul>

It drops the text below the bullet point - will this be fixed?.

o

     Some text.

Posted by admin  · 06-07-2017 - 15:37

Hello,

You are adding a paragraph inside a list item, so when phpdocx transforms HTML to DOCX it generates a w:p for the list item and other w:p for the paragraph (both elements are paragraph in OOXML).

We recommend you to avoid adding a paragraph element inside a list item:

$docx->embedHTML('<ul><li>Some text.</li></ul>');

or use an inline tag:

$docx->embedHTML('<ul><li><span>Some text</span>.</li></ul>');

Regards.

Posted by nohope100  · 07-07-2017 - 08:42

Yes the best option is not to add the p tags but this is data that is already stored in a database. Is there a quick regex fix for this or any other fix I could use?

Posted by admin  · 07-07-2017 - 08:47

Hello,

Which version and license of phpdocx are you using?

Regards.

Posted by nohope100  · 07-07-2017 - 08:57

Corporate
Version    Domain / IP    License Update Service
6.0    

Posted by admin  · 07-07-2017 - 09:46

Hello,

We recommend you to remove them before transforming HTML to DOCX.

This is using a regex such as;

$html = preg_replace('/<\\/?p(.|\\s)*?>/', '', $html);

or str_replace:

$tags = array('<p>', '</p>');
$html = str_replace($tags, '', $html);

You need to change these codes if there're other paragraphs you need to keep or lists are not added standalone but with more HTML.

You can also use DOCXPath to move contents after transforming the HTML, but the easiest solution is cleaning the HTML before being added.

Regards.

Posted by nohope100  · 12-07-2017 - 10:25

Thanks you..

As I have a version 6 license is there an upgrade I can download that is below version 7?

Is there a version 6.5?

Posted by admin  · 12-07-2017 - 11:02

Hello,

On MY PHPDOCX page you can see the latest version available to download for the account. If you want to upgrade a license to the latest version, on this same page there's a button to do the upgrading.

phpdocx 7 is fully compatible with all scripts created with phpdocx 6 (if you use DOCXPath you need to use 'occurrence' option instead of 'ocurrence').

Regards.