Forum


Replies: 2   Views: 169
Ol and customliststyles are not thoroughly supported

Posted by msun  · 05-06-2020 - 20:38

We just upgraded to phpdocx v9.5 specifically hoping to address difficulties involving lists.

I'm finding that when we define a custom list-style, phpdocx yields an error when it encounters an OL element.

>>DOMDocument::loadXML() expects parameter 1 to be string, object given in file ....phpdocx/classes/CreateDocx.php on line 5164

https://www.phpdocx.com/en/forum/default/topic/1857

In this other thread, you indicate that this is basically by design:
>>To apply custom list styles, you need to use ul tags, not ol

Yet elsewhere in the documentation, you indicate:
>>Supported HTML tags and attributes
>>ul and ol: Are respectively parsed as unordered or ordered Word lists.

All of this particular behavior was working fine in previous versions. Would you agree that forcing us to use UL instead of OL violates the entire notion of the "HTML to DOCX" paradigm?

I understand that this is how DOCX works under the hood, but that's besides the point. Your users expect to be able to convert HTML into DOCX without jumping through hoops.

I'm finding that I must now refactor old logic to keep it in line with this new requirement, as well as add extra logic to address the requirement.

I hope that this will be addressed in the next version.

Posted by admin  · 06-06-2020 - 09:46

Hello,

Please do this minor change:

1. Edit CreateDocx.php (Classes/Phpdocx/Create folder in the namespaces package).

2. Go to embedHTML method.

3. Replace the following line:

if (isset($value['attributes'])) {

by:

if (isset($value['attributes']) && $newNumberingDOM) {

And try again. A very similar change will be included in the next release of phpdocx to allows adding customListStyles with ol tags.

Regards.

Posted by admin  · 30-06-2020 - 17:59

Hello,

phpdocx 10 added support to use customListStyles with ol tags.

Regards.