Forum


Replies: 7   Views: 1413
How to create heading with formatstyles in embedhtml?
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-12-2020 - 15:47

Hello,

UPDATE: https://www.phpdocx.com/documentation/cookbook/working-with-headings

If you run

$docx->addText('Contents',array('pStyle' => 'Heading1'));

and you don't get a custom paragraph style applied to that content is because your DOCX doesn't include that style name (Heading1). Please test and run the included sample Core/addTableContents/sample_2.php that applies custom paragraph styles included in the default template of phpdocx, for example:

$docx->addText('Chapter 1', array('pStyle' => 'Heading1PHPDOCX'));

If you don't know the name of the style/s you want to apply, you can get them using importStyles (https://www.phpdocx.com/api-documentation/layout-and-general/import-styles-from-a-Word-document-with-PHP). On https://www.phpdocx.com/documentation/practical/styles you can read the practical guide about using styles with phpdocx.

Regards.