Forum


Replies: 3   Views: 1373
Html to docx conversion does not create headings in word?
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  · 19-01-2021 - 08:38

Hello,

UPDATE: Working with headings using PHP methods and HTML contents

To use other style names than the default ones, you can use a custom template (with data or empty) or generate the styles dynamically with phpdocx methods. If you want to use the default MS Word style names (that don't have always names such as Heading1, because style names may depend on the DOCX program used to generate the document and the language of the DOCX editor), you can create an empty template (with MS Word or other DOCX program) and open it with the CreateDocxFromTemplate class:

$docx = new CreateDocxFromTemplate('template.docx');

CreateDocxFromTemplate inherits CreateDocx, so you can use the methods available in both classes.

Using the parseStyles method you can generate a DOCX with the existing styles in the template. And also use importStyles to import styles from an external DOCX if needed.

As you are using the trial package, we recommend you to read the documentation available, for example on the Practical guide: https://www.phpdocx.com/documentation/practical. If you purchase a license, do not hesitate to send an email to contact[at]phpdocx.com, we'll generate a custom template and script that illustrates how to use an empty template and its styles if needed.

Regards.