Forum


Replies: 4   Views: 1639
How to use div tags properly when importing html?
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  · 14-01-2021 - 15:30

Hello,

Getting the same DOCX output than the linked image depends on the HTML tags and CSS styles it uses. phpdocx supports many HTML tags and CSS styles, and Premium licenses also extend them adding custom HTML tags and CSS styles (mainly to add support not standard HTML and CSS, for example to allow adding a TOC using a tag or set MS Word styles using data attributes), but to transform HTML and CSS correctly, the contents and styles need to be supported and have an equivalent to MS Word.

You can get the same output you need but if your WYSIWYG editor uses the supported HTML and CSS. All supported tags, attributes and styles by HTML to DOCX feature are detailed on the HTML API documentation: https://www.phpdocx.com/documentation/htmlapi-documentation. For example:

· p tags (https://www.phpdocx.com/htmlapi-documentation/html-standard/insert-paragraph-text-Word-document-with-HTML) as you can check on this same page, some styles may not be supported, for example setting width to a paragraph is not supported because MS Word doesn't support it.

· span tags (https://www.phpdocx.com/htmlapi-documentation/html-standard/insert-span-text-Word-document-with-HTML), for example text-align isn't supported because MS Word doesn't allow setting it to run-of-text contents; text-align needs to be applied to block tags such as p or div or table.

We never ask users to get familiar with the internal DOCX structure but HTML to DOCX is limited by the contents and styles supported by MS Word and how they are handled.

Regards.